From f062bbd7a182233f96c61287d0397534811627d9 Mon Sep 17 00:00:00 2001 From: kwolekr Date: Wed, 23 Sep 2015 00:31:45 -0400 Subject: Add /emergeblocks command and core.emerge_area() Lua API --- builtin/game/misc.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'builtin/game/misc.lua') 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 -- cgit v1.2.3