diff options
author | orwell96 <mono96.mml@gmail.com> | 2017-02-04 18:35:34 +0100 |
---|---|---|
committer | orwell96 <mono96.mml@gmail.com> | 2017-02-04 18:35:34 +0100 |
commit | 61e48fff280075ec52bfaa31644c22b08814d680 (patch) | |
tree | c7cac2a799bfe4bf6f180617f96c1035e04b26df /advtrains/advtrains | |
parent | 1e3bd3a5fd5d448fa123ba02012f935fbc29880a (diff) | |
download | advtrains-61e48fff280075ec52bfaa31644c22b08814d680.tar.gz advtrains-61e48fff280075ec52bfaa31644c22b08814d680.tar.bz2 advtrains-61e48fff280075ec52bfaa31644c22b08814d680.zip |
Commit 1.6.2
- Add some more stuff to API for LuaATC rails
- Warn on strange events even if debug info is disabled
- save atlatc on shutdown too
- fix detector rails in unloaded chunks
- do not fail silently in simple ATC rails
Diffstat (limited to 'advtrains/advtrains')
-rw-r--r-- | advtrains/advtrains/atc.lua | 18 | ||||
-rw-r--r-- | advtrains/advtrains/init.lua | 5 | ||||
-rw-r--r-- | advtrains/advtrains/tracks.lua | 4 |
3 files changed, 22 insertions, 5 deletions
diff --git a/advtrains/advtrains/atc.lua b/advtrains/advtrains/atc.lua index 609857b..bf94ba5 100644 --- a/advtrains/advtrains/atc.lua +++ b/advtrains/advtrains/atc.lua @@ -41,10 +41,22 @@ function atc.send_command(pos) ) advtrains.trains[train_id].atc_command=atc.controllers[pts].command atprint("Sending ATC Command: "..atc.controllers[pts].command) + return true end end + atwarn("ATC rail at", pos, ": Rail not on train's path! Can't determine arrow direction. Assuming +!") + advtrains.trains[train_id].atc_arrow=true + advtrains.trains[train_id].atc_command=atc.controllers[pts].command + atprint("Sending ATC Command: "..atc.controllers[pts].command) + else + atwarn("ATC rail at", pos, ": Sending command failed: The train",train_id,"does not exist. This seems to be a bug.") end + else + atwarn("ATC rail at", pos, ": Sending command failed: There's no train at this position. This seems to be a bug.") end + else + atwarn("ATC rail at", pos, ": Sending command failed: Entry for controller not found.") + atwarn("ATC rail at", pos, ": Please visit controller and click 'Save'") end return false end @@ -182,7 +194,7 @@ local matchptn={ train.movedir=train.movedir*-1 train.atc_arrow = not train.atc_arrow else - minetest.chat_send_all(attrans("ATC Reverse command warning: didn't reverse train, train moving!")) + atwarn(sid(id), attrans("ATC Reverse command warning: didn't reverse train, train moving!")) end return 1 end, @@ -241,7 +253,7 @@ function atc.execute_atc_command(id, train) local nest, pos, elsepos=0, 1 while nest>=0 do if pos>#rest then - minetest.chat_send_all(attrans("ATC command syntax error: I statement not closed: @1",command)) + atwarn(sid(id), attrans("ATC command syntax error: I statement not closed: @1",command)) atc.train_reset_command(id) return end @@ -284,7 +296,7 @@ function atc.execute_atc_command(id, train) end end end - minetest.chat_send_all(attrans("ATC command parse error: Unknown command: @1", command)) + atwarn(sid(id), attrans("ATC command parse error: Unknown command: @1", command)) atc.train_reset_command(id) end diff --git a/advtrains/advtrains/init.lua b/advtrains/advtrains/init.lua index 5ae5e80..c60b2f1 100644 --- a/advtrains/advtrains/init.lua +++ b/advtrains/advtrains/init.lua @@ -49,6 +49,11 @@ if minetest.setting_getbool("advtrains_debug") then minetest.chat_send_all("[advtrains]"..text) end end +atwarn=function(t, ...) + local text=advtrains.print_concat_table({t, ...}) + minetest.log("warning", "[advtrains]"..text) + minetest.chat_send_all("[advtrains] -!- "..text) +end sid=function(id) return string.sub(id, -4) end dofile(advtrains.modpath.."/helpers.lua"); diff --git a/advtrains/advtrains/tracks.lua b/advtrains/advtrains/tracks.lua index c5ab436..63c4f16 100644 --- a/advtrains/advtrains/tracks.lua +++ b/advtrains/advtrains/tracks.lua @@ -615,7 +615,7 @@ if mesecon then },
advtrains = {
on_train_enter=function(pos, train_id)
- minetest.swap_node(pos, {name="advtrains:dtrack_detector_on".."_"..suffix..rotation, param2=minetest.get_node(pos).param2})
+ advtrains.ndb.swap_node(pos, {name="advtrains:dtrack_detector_on".."_"..suffix..rotation, param2=minetest.get_node(pos).param2})
mesecon.receptor_on(pos, advtrains.meseconrules)
end
}
@@ -640,7 +640,7 @@ if mesecon then },
advtrains = {
on_train_leave=function(pos, train_id)
- minetest.swap_node(pos, {name="advtrains:dtrack_detector_off".."_"..suffix..rotation, param2=minetest.get_node(pos).param2})
+ advtrains.ndb.swap_node(pos, {name="advtrains:dtrack_detector_off".."_"..suffix..rotation, param2=minetest.get_node(pos).param2})
mesecon.receptor_off(pos, advtrains.meseconrules)
end
}
|