make switches not switchable when train is on it, and do neccessary stuff on switching

This commit is contained in:
orwell96 2016-09-13 16:18:57 +02:00
parent 173829fe59
commit a93fb4345e
1 changed files with 5 additions and 6 deletions

View File

@ -159,15 +159,14 @@ local t_45deg={
}]] }]]
function advtrains.register_tracks(tracktype, def, preset) function advtrains.register_tracks(tracktype, def, preset)
local function make_switchfunc(suffix_target, mesecon_state) local function make_switchfunc(suffix_target, mesecon_state)
return function(pos, node) local switchfunc=function(pos, node)
if advtrains.is_train_at_pos(pos) then return end if advtrains.is_train_at_pos(pos) then return end
advtrains.invalidate_all_paths()
minetest.set_node(pos, {name=def.nodename_prefix.."_"..suffix_target, param2=node.param2}) minetest.set_node(pos, {name=def.nodename_prefix.."_"..suffix_target, param2=node.param2})
advtrains.invalidate_all_paths()
advtrains.reset_trackdb_position(pos) advtrains.reset_trackdb_position(pos)
end, {effector = { end
["action_"..mesecon_state] = function (pos, node) return switchfunc, {effector = {
minetest.swap_node(pos, {name=def.nodename_prefix.."_"..suffix_target, param2=node.param2}) ["action_"..mesecon_state] = switchfunc
end
}} }}
end end
local function make_overdef(suffix, rotation, conns, switchfunc, mesecontbl, in_creative_inv) local function make_overdef(suffix, rotation, conns, switchfunc, mesecontbl, in_creative_inv)