Make is_node_loaded() checks also for mesecon interactions and digiline_send(), move on_updated_from_nodedb to advtrains table
This commit is contained in:
parent
8ae405f00f
commit
e935136d58
|
@ -294,11 +294,12 @@ ndb.run_lbm = function(pos, node)
|
||||||
ndb.update(pos, node)
|
ndb.update(pos, node)
|
||||||
else
|
else
|
||||||
if (nodeid~=node.name or param2~=node.param2) then
|
if (nodeid~=node.name or param2~=node.param2) then
|
||||||
atprint("nodedb: lbm replaced", pos, "with nodeid", nodeid, "param2", param2, "cid is", cid)
|
--atprint("nodedb: lbm replaced", pos, "with nodeid", nodeid, "param2", param2, "cid is", cid)
|
||||||
minetest.swap_node(pos, {name=nodeid, param2 = param2})
|
local newnode = {name=nodeid, param2 = param2}
|
||||||
|
minetest.swap_node(pos, newnode)
|
||||||
local ndef=minetest.registered_nodes[nodeid]
|
local ndef=minetest.registered_nodes[nodeid]
|
||||||
if ndef and ndef.on_updated_from_nodedb then
|
if ndef and ndef.advtrains and ndef.advtrains.on_updated_from_nodedb then
|
||||||
ndef.on_updated_from_nodedb(pos, node)
|
ndef.advtrains.on_updated_from_nodedb(pos, newnode)
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,17 +13,19 @@ minetest.override_item("mesecons_switch:mesecon_switch_off", {
|
||||||
mesecon.receptor_on(pos)
|
mesecon.receptor_on(pos)
|
||||||
minetest.sound_play("mesecons_switch", {pos=pos})
|
minetest.sound_play("mesecons_switch", {pos=pos})
|
||||||
end,
|
end,
|
||||||
on_updated_from_nodedb = function(pos, node)
|
|
||||||
mesecon.receptor_off(pos)
|
|
||||||
end,
|
|
||||||
advtrains = {
|
advtrains = {
|
||||||
getstate = "off",
|
getstate = "off",
|
||||||
setstate = function(pos, node, newstate)
|
setstate = function(pos, node, newstate)
|
||||||
if newstate=="on" then
|
if newstate=="on" then
|
||||||
advtrains.ndb.swap_node(pos, {name="mesecons_switch:mesecon_switch_on", param2=node.param2})
|
advtrains.ndb.swap_node(pos, {name="mesecons_switch:mesecon_switch_on", param2=node.param2})
|
||||||
mesecon.receptor_on(pos)
|
if advtrains.is_node_loaded(pos) then
|
||||||
|
mesecon.receptor_on(pos)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
on_updated_from_nodedb = function(pos, node)
|
||||||
|
mesecon.receptor_off(pos)
|
||||||
|
end,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -38,17 +40,19 @@ minetest.override_item("mesecons_switch:mesecon_switch_on", {
|
||||||
mesecon.receptor_off(pos)
|
mesecon.receptor_off(pos)
|
||||||
minetest.sound_play("mesecons_switch", {pos=pos})
|
minetest.sound_play("mesecons_switch", {pos=pos})
|
||||||
end,
|
end,
|
||||||
on_updated_from_nodedb = function(pos, node)
|
|
||||||
mesecon.receptor_on(pos)
|
|
||||||
end,
|
|
||||||
advtrains = {
|
advtrains = {
|
||||||
getstate = "on",
|
getstate = "on",
|
||||||
setstate = function(pos, node, newstate)
|
setstate = function(pos, node, newstate)
|
||||||
if newstate=="off" then
|
if newstate=="off" then
|
||||||
advtrains.ndb.swap_node(pos, {name="mesecons_switch:mesecon_switch_off", param2=node.param2})
|
advtrains.ndb.swap_node(pos, {name="mesecons_switch:mesecon_switch_off", param2=node.param2})
|
||||||
mesecon.receptor_off(pos)
|
if advtrains.is_node_loaded(pos) then
|
||||||
|
mesecon.receptor_off(pos)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
fallback_state = "off",
|
fallback_state = "off",
|
||||||
|
on_updated_from_nodedb = function(pos, node)
|
||||||
|
mesecon.receptor_on(pos)
|
||||||
|
end,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -125,7 +125,9 @@ function ac.run_in_env(pos, evtdata, customfct_p)
|
||||||
if minetest.global_exists("digiline") then
|
if minetest.global_exists("digiline") then
|
||||||
customfct.digiline_send=function(channel, msg)
|
customfct.digiline_send=function(channel, msg)
|
||||||
assertt(channel, "string")
|
assertt(channel, "string")
|
||||||
digiline:receptor_send(pos, digiline.rules.default, channel, msg)
|
if advtrains.is_node_loaded(pos) then
|
||||||
|
digiline:receptor_send(pos, digiline.rules.default, channel, msg)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- add lines scheduler if enabled
|
-- add lines scheduler if enabled
|
||||||
|
|
|
@ -318,9 +318,14 @@ if mesecon then
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
advtrains = {
|
advtrains = {
|
||||||
|
on_updated_from_nodedb = function(pos, node)
|
||||||
|
mesecon.receptor_off(pos, advtrains.meseconrules)
|
||||||
|
end,
|
||||||
on_train_enter=function(pos, train_id)
|
on_train_enter=function(pos, train_id)
|
||||||
advtrains.ndb.swap_node(pos, {name="advtrains:dtrack_detector_on".."_"..suffix..rotation, param2=advtrains.ndb.get_node(pos).param2})
|
advtrains.ndb.swap_node(pos, {name="advtrains:dtrack_detector_on".."_"..suffix..rotation, param2=advtrains.ndb.get_node(pos).param2})
|
||||||
mesecon.receptor_on(pos, advtrains.meseconrules)
|
if advtrains.is_node_loaded(pos) then
|
||||||
|
mesecon.receptor_on(pos, advtrains.meseconrules)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -343,9 +348,14 @@ if mesecon then
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
advtrains = {
|
advtrains = {
|
||||||
|
on_updated_from_nodedb = function(pos, node)
|
||||||
|
mesecon.receptor_on(pos, advtrains.meseconrules)
|
||||||
|
end,
|
||||||
on_train_leave=function(pos, train_id)
|
on_train_leave=function(pos, train_id)
|
||||||
advtrains.ndb.swap_node(pos, {name="advtrains:dtrack_detector_off".."_"..suffix..rotation, param2=advtrains.ndb.get_node(pos).param2})
|
advtrains.ndb.swap_node(pos, {name="advtrains:dtrack_detector_off".."_"..suffix..rotation, param2=advtrains.ndb.get_node(pos).param2})
|
||||||
mesecon.receptor_off(pos, advtrains.meseconrules)
|
if advtrains.is_node_loaded(pos) then
|
||||||
|
mesecon.receptor_off(pos, advtrains.meseconrules)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue