Skip to content

Commit

Permalink
load target area of teleport destination / teleport _above_ bones
Browse files Browse the repository at this point in the history
fixes #8
  • Loading branch information
BuckarooBanzay committed Nov 6, 2020
1 parent 52b5c97 commit 1859503
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions bridge/search.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,24 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end

if fields.teleport then
-- teleport player to selected item
if not minetest.check_player_privs(playername, "teleport") then
minetest.chat_send_player(playername, "Missing priv: 'teleport'")
return
end

-- flat destination coordinates per default
local pos1 = vector.subtract(item.pos, {x=2, y=0, z=2})
local pos2 = vector.add(item.pos, {x=2, y=0, z=2})

if item.type == "bones" then
-- search for air _above_ the bones
pos1 = vector.subtract(item.pos, {x=0, y=0, z=0})
pos2 = vector.add(item.pos, {x=0, y=10, z=0})
end

-- forceload target coordinates before searching for air
minetest.get_voxel_manip():read_from_map(pos1, pos2)
local nodes = minetest.find_nodes_in_area(pos1, pos2, "air")

if #nodes > 0 then
Expand Down

0 comments on commit 1859503

Please sign in to comment.