diff options
author | orwell96 <mono96.mml@gmail.com> | 2016-09-13 16:18:57 +0200 |
---|---|---|
committer | orwell96 <mono96.mml@gmail.com> | 2016-09-13 16:18:57 +0200 |
commit | a93fb4345e084a0fc67656b85084d9841a3c5ec9 (patch) | |
tree | 8f179af73990af9f1d479f9b8dbd43b3acc8a6d2 /tracks.lua | |
parent | 173829fe5918cef85999f925f397d14ce36c2cc2 (diff) | |
download | advtrains-a93fb4345e084a0fc67656b85084d9841a3c5ec9.tar.gz advtrains-a93fb4345e084a0fc67656b85084d9841a3c5ec9.tar.bz2 advtrains-a93fb4345e084a0fc67656b85084d9841a3c5ec9.zip |
make switches not switchable when train is on it, and do neccessary stuff on switching
Diffstat (limited to 'tracks.lua')
-rw-r--r-- | tracks.lua | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -159,15 +159,14 @@ local t_45deg={ }]]
function advtrains.register_tracks(tracktype, def, preset)
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
- advtrains.invalidate_all_paths()
minetest.set_node(pos, {name=def.nodename_prefix.."_"..suffix_target, param2=node.param2})
+ advtrains.invalidate_all_paths()
advtrains.reset_trackdb_position(pos)
- end, {effector = {
- ["action_"..mesecon_state] = function (pos, node)
- minetest.swap_node(pos, {name=def.nodename_prefix.."_"..suffix_target, param2=node.param2})
- end
+ end
+ return switchfunc, {effector = {
+ ["action_"..mesecon_state] = switchfunc
}}
end
local function make_overdef(suffix, rotation, conns, switchfunc, mesecontbl, in_creative_inv)
|