aboutsummaryrefslogtreecommitdiff
path: root/advtrains
diff options
context:
space:
mode:
Diffstat (limited to 'advtrains')
-rw-r--r--advtrains/advtrains/wagons.lua22
1 files changed, 13 insertions, 9 deletions
diff --git a/advtrains/advtrains/wagons.lua b/advtrains/advtrains/wagons.lua
index 1a889b5..4b080a5 100644
--- a/advtrains/advtrains/wagons.lua
+++ b/advtrains/advtrains/wagons.lua
@@ -346,16 +346,20 @@ function wagon:on_step(dtime)
-- the two wanted positions are ix1 and ix2 + (2nd-1st rotated by 90deg)
-- (x z) rotated by 90deg is (-z x) (http://stackoverflow.com/a/4780141)
local add = { x = (ix2.z-ix1.z)*gp.door_open, y = 0, z = (ix1.x-ix2.x)*gp.door_open }
- local pts1=minetest.pos_to_string(vector.round(vector.add(ix1, add)))
- local pts2=minetest.pos_to_string(vector.round(vector.add(ix2, add)))
-
- if advtrains.playersbypts[pts1] then
- self:on_rightclick(advtrains.playersbypts[pts1])
- end
- if advtrains.playersbypts[pts2] then
- self:on_rightclick(advtrains.playersbypts[pts2])
+ local pts1=vector.round(vector.add(ix1, add))
+ local pts2=vector.round(vector.add(ix2, add))
+ local ckpts={
+ pts1,
+ pts2,
+ vector.add(pts1, {x=0, y=1, z=0}),
+ vector.add(pts2, {x=0, y=1, z=0}),
+ }
+ for _,ckpos in ipairs(ckpts) do
+ local cpp=minetest.pos_to_string(ckpos)
+ if advtrains.playersbypts[cpp] then
+ self:on_rightclick(advtrains.playersbypts[cpp])
+ end
end
-
end
end
l kwd">swap_node(pos, {name="mesecons_switch:mesecon_switch_on", param2=node.param2}) mesecon.receptor_on(pos) end end, }, }) minetest.override_item("mesecons_switch:mesecon_switch_on", { groups = { dig_immediate=2, save_in_nodedb=1, not_in_creative_inventory=1, }, on_rightclick = function (pos, node) advtrains.ndb.swap_node(pos, {name="mesecons_switch:mesecon_switch_off", param2=node.param2}) mesecon.receptor_off(pos) minetest.sound_play("mesecons_switch", {pos=pos}) end, on_updated_from_nodedb = function(pos, node) mesecon.receptor_on(pos) end, luaautomation = { getstate = "on", setstate = function(pos, node, newstate) if newstate=="off" then advtrains.ndb.swap_node(pos, {name="mesecons_switch:mesecon_switch_off", param2=node.param2}) mesecon.receptor_off(pos) end end, }, })