From aeaca5d7494efe55767c997181a5c071c4800c43 Mon Sep 17 00:00:00 2001 From: Fernando Carmona Varo Date: Sat, 7 Nov 2015 10:27:05 +0100 Subject: Some refactoring for the on_player_collision --- mario/portal.lua | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'mario/portal.lua') diff --git a/mario/portal.lua b/mario/portal.lua index eb04b93..1ff31ee 100644 --- a/mario/portal.lua +++ b/mario/portal.lua @@ -9,6 +9,9 @@ minetest.register_node("mario:portal", { walkable = false, is_ground_content = false, groups = {cracky = 2,not_in_creative_inventory=1}, + on_player_collision = function(pos, player, gameid) + player:setpos({x=pos.x,y=pos.y+12,z=pos.z}) + end }) minetest.register_node("mario:portal_left", { description = "Portal Left", @@ -20,6 +23,9 @@ minetest.register_node("mario:portal_left", { --walkable = false, is_ground_content = false, groups = {cracky = 2,not_in_creative_inventory=0}, + on_player_collision = function(pos, player, gameid) + player:setpos(vector.add(pos,{x=31, y=0, z=0})) + end }) minetest.register_node("mario:portal_right", { description = "Portal Right", @@ -31,18 +37,7 @@ minetest.register_node("mario:portal_right", { --walkable = false, is_ground_content = false, groups = {cracky = 2,not_in_creative_inventory=0}, -}) -minetest.register_abm({ - nodenames = {"mario:portal"}, - 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, 1) - for k, player in pairs(objs) do - if player:get_player_name() then - - player:setpos({x=pos.x,y=pos.y+12,z=pos.z}) - end - end + on_player_collision = function(pos, player, gameid) + player:setpos(vector.add(pos,{x=-31, y=0, z=0})) end }) -- cgit v1.2.3