diff options
author | Fernando Carmona Varo <ferkiwi@gmail.com> | 2015-11-07 09:57:35 +0100 |
---|---|---|
committer | Fernando Carmona Varo <ferkiwi@gmail.com> | 2015-11-07 09:57:35 +0100 |
commit | 234cac868e1baf2089ef255d0751a7e288725db5 (patch) | |
tree | c1e5fda83009858772e62a3569123384ae58c729 | |
parent | 6b5cbd4939b4f461e89f2c2ce79640aeae72a0c7 (diff) |
Improved portal detection, using the already existing collision detection logic instead of abms
-rwxr-xr-x | mario/gamestate.lua | 6 | ||||
-rw-r--r-- | mario/portal.lua | 28 |
2 files changed, 6 insertions, 28 deletions
diff --git a/mario/gamestate.lua b/mario/gamestate.lua index 2572a99..1ccf4a7 100755 --- a/mario/gamestate.lua +++ b/mario/gamestate.lua @@ -268,6 +268,12 @@ local function on_player_gamestep(player, gameid) elseif node.name == "mario:mushroom" then minetest.remove_node(pos) mario.on_player_got_mushroom(player, 15) + elseif node.name == "mario:portal_right" then + player_pos.x = player_pos.x -31 + player:setpos(player_pos) + elseif node.name == "mario:portal_left" then + player_pos.x = player_pos.x +31 + player:setpos(player_pos) end end end diff --git a/mario/portal.lua b/mario/portal.lua index 7b9945d..eb04b93 100644 --- a/mario/portal.lua +++ b/mario/portal.lua @@ -46,31 +46,3 @@ minetest.register_abm({ end end }) -minetest.register_abm({ - nodenames = {"mario:portal_left"}, - interval = 0.5, - chance = 1, - action = function(pos, node, active_object_count, active_object_count_wider) - local objs = minetest.env:get_objects_inside_radius(pos, 2) - for k, player in pairs(objs) do - if player:get_player_name() then - - player:setpos({x=pos.x+31,y=pos.y+0.5,z=pos.z}) - end - end - end -}) -minetest.register_abm({ - nodenames = {"mario:portal_right"}, - interval = 0.5, - chance = 1, - action = function(pos, node, active_object_count, active_object_count_wider) - local objs = minetest.env:get_objects_inside_radius(pos, 2) - for k, player in pairs(objs) do - if player:get_player_name() then - - player:setpos({x=pos.x-31,y=pos.y+0.5,z=pos.z}) - end - end - end -}) |