summaryrefslogtreecommitdiff
path: root/stargate/gate_defs.lua
diff options
context:
space:
mode:
Diffstat (limited to 'stargate/gate_defs.lua')
-rw-r--r--stargate/gate_defs.lua25
1 files changed, 15 insertions, 10 deletions
diff --git a/stargate/gate_defs.lua b/stargate/gate_defs.lua
index 47e45a1..caca8ca 100644
--- a/stargate/gate_defs.lua
+++ b/stargate/gate_defs.lua
@@ -138,7 +138,7 @@ function placeGate (player,pos)
minetest.env:set_node(gateNodes[8].pos,{name="stargate:gatenode1_off", param1=0, param2=dir})
minetest.env:set_node(gateNodes[9].pos,{name="stargate:gatenode3_off", param1=0, param2=dir})
local meta = minetest.env:get_meta(gateNodes[1].pos)
- meta:set_string("infotext", "Stargate inactive\nOwned by: "..player_name)
+ meta:set_string("infotext", "Stargate\nOwned by: "..player_name)
meta:set_string("gateNodes",minetest.serialize(gateNodes))
meta:set_int("gateActive",0)
meta:set_string("owner",player_name)
@@ -158,13 +158,12 @@ function removeGate (pos)
stargate.unregisterGate(player_name,gateNodes[1].pos)
end
-function activateGate (player,pos)
+function activateGate (pos)
local node = minetest.env:get_node(pos)
local dir=node.param2
local meta = minetest.env:get_meta(pos)
local gateNodes=minetest.deserialize(meta:get_string("gateNodes"))
meta:set_int("gateActive",1)
- meta:set_string("infotext", "Stargate active")
meta:set_string("dont_destroy","true")
minetest.sound_play("gateOpen", {pos = pos, gain = 1.0,loop = false, max_hear_distance = 72,})
swap_gate_node(gateNodes[1].pos,"stargate:gatenode8",dir)
@@ -179,14 +178,13 @@ function activateGate (player,pos)
meta:set_string("dont_destroy","false")
end
-function deactivateGate (player,pos)
+function deactivateGate (pos)
local node = minetest.env:get_node(pos)
local dir=node.param2
local meta = minetest.env:get_meta(pos)
local gateNodes=minetest.deserialize(meta:get_string("gateNodes"))
meta:set_int("gateActive",0)
meta:set_string("dont_destroy","true")
- meta:set_string("infotext", "Stargate inactive")
minetest.sound_play("gateClose", {pos = pos, gain = 1.0,loop = false, max_hear_distance = 72,})
swap_gate_node(gateNodes[1].pos,"stargate:gatenode8_off",dir)
swap_gate_node(gateNodes[2].pos,"stargate:gatenode7_off",dir)
@@ -486,13 +484,22 @@ minetest.register_abm({
for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, 1)) do
if object:is_player() then
local player_name = object:get_player_name()
- local gate=stargate.getCurrentGate (player_name,pos)
+ local owner=meta:get_string("owner")
+ local gate=stargate.findGate (pos)
+ if gate==nil then print("Gate is not registered!") return end
local pos1={}
pos1.x=gate["destination"].x
pos1.y=gate["destination"].y
pos1.z=gate["destination"].z
+ local dest_gate=stargate.findGate (pos1)
+ if dest_gate==nil then
+ gate["destination"]=nil
+ deactivateGate(pos)
+ stargate.save_data(owner)
+ return
+ end
+ if player_name~=owner and gate["type"]=="private" then return end
local dir1=gate["destination_dir"]
- local dir=minetest.dir_to_facedir(object:get_look_dir())
if dir1 == 0 then
pos1.z=pos1.z+2
elseif dir1 == 1 then
@@ -502,10 +509,8 @@ minetest.register_abm({
elseif dir1 == 3 then
pos1.x=pos1.x-2
end
- object:moveto(pos1,true)
- print(dump(gate["dest"]))
+ object:moveto(pos1,false)
minetest.sound_play("enterEventHorizon", {pos = pos, gain = 1.0,loop = false, max_hear_distance = 72,})
-
end
end
end