diff options
author | kwolekr <kwolekr@minetest.net> | 2015-09-23 00:31:45 -0400 |
---|---|---|
committer | kwolekr <kwolekr@minetest.net> | 2015-09-23 15:56:24 -0400 |
commit | f062bbd7a182233f96c61287d0397534811627d9 (patch) | |
tree | df3d2252f8bbb9975669c7920b57dce2fb3d3df6 /builtin/game/misc.lua | |
parent | 596484da4fcd301e597a851a9a54b6dc276a286a (diff) | |
download | minetest-f062bbd7a182233f96c61287d0397534811627d9.tar.gz minetest-f062bbd7a182233f96c61287d0397534811627d9.tar.bz2 minetest-f062bbd7a182233f96c61287d0397534811627d9.zip |
Add /emergeblocks command and core.emerge_area() Lua API
Diffstat (limited to 'builtin/game/misc.lua')
-rw-r--r-- | builtin/game/misc.lua | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/builtin/game/misc.lua b/builtin/game/misc.lua index e3b7d82bc..dee419767 100644 --- a/builtin/game/misc.lua +++ b/builtin/game/misc.lua @@ -109,6 +109,25 @@ function core.get_connected_players() return temp_table end +-- Returns two position vectors representing a box of `radius` in each +-- direction centered around the player corresponding to `player_name` +function core.get_player_radius_area(player_name, radius) + local player = core.get_player_by_name(player_name) + if player == nil then + return nil + end + + local p1 = player:getpos() + local p2 = p1 + + if radius then + p1 = vector.subtract(p1, radius) + p2 = vector.add(p2, radius) + end + + return p1, p2 +end + function core.hash_node_position(pos) return (pos.z+32768)*65536*65536 + (pos.y+32768)*65536 + pos.x+32768 end |