diff options
author | orwell96 <orwell@bleipb.de> | 2020-07-07 14:25:47 +0200 |
---|---|---|
committer | orwell96 <orwell@bleipb.de> | 2020-07-07 14:25:47 +0200 |
commit | f33bb563e78a62cc8fb2e1483a6cb9a2436b708a (patch) | |
tree | a3690d6dbc6a04c82e4aad78f3fb5d2f90fa533d /advtrains/passive.lua | |
parent | 96236c04dc790cbcd4d8cb52aee5563f54e736aa (diff) | |
download | advtrains-f33bb563e78a62cc8fb2e1483a6cb9a2436b708a.tar.gz advtrains-f33bb563e78a62cc8fb2e1483a6cb9a2436b708a.tar.bz2 advtrains-f33bb563e78a62cc8fb2e1483a6cb9a2436b708a.zip |
Add "Fallback state" for freed routes, move p_mesecon_iface.lua to core
Diffstat (limited to 'advtrains/passive.lua')
-rw-r--r-- | advtrains/passive.lua | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/advtrains/passive.lua b/advtrains/passive.lua index 07cab42..fe4790c 100644 --- a/advtrains/passive.lua +++ b/advtrains/passive.lua @@ -97,3 +97,25 @@ function advtrains.is_passive(parpos, pnode) return false end end + +-- switches a node back to fallback state, if defined. Doesn't support pcnaming. +function advtrains.set_fallback_state(pos, pnode) + local node=pnode or advtrains.ndb.get_node(pos) + local ndef=minetest.registered_nodes[node.name] + local st + if ndef and ndef.advtrains and ndef.advtrains.setstate + and ndef.advtrains.fallback_state then + if advtrains.get_train_at_pos(pos) then + return false + end + + if advtrains.interlocking and advtrains.interlocking.route.has_route_lock(minetest.pos_to_string(pos)) then + return false + end + + ndef.advtrains.setstate(pos, node, ndef.advtrains.fallback_state) + return true + end + + +end |