diff options
author | orwell96 <orwell@bleipb.de> | 2020-04-27 16:02:28 +0200 |
---|---|---|
committer | orwell96 <orwell@bleipb.de> | 2021-02-10 16:36:24 +0100 |
commit | 5c2534cc35bc0fc47b53c8a992e3e71b15a60ec4 (patch) | |
tree | 5c72e9e541401126d5416b6d122893c300b88bea /advtrains/atc.lua | |
parent | b59b0d587d72f78c5923aa501038b93269bba271 (diff) | |
download | advtrains-5c2534cc35bc0fc47b53c8a992e3e71b15a60ec4.tar.gz advtrains-5c2534cc35bc0fc47b53c8a992e3e71b15a60ec4.tar.bz2 advtrains-5c2534cc35bc0fc47b53c8a992e3e71b15a60ec4.zip |
Remove pcall wrappers completely, add command to disable advtrains mainloop
Diffstat (limited to 'advtrains/atc.lua')
-rw-r--r-- | advtrains/atc.lua | 80 |
1 files changed, 38 insertions, 42 deletions
diff --git a/advtrains/atc.lua b/advtrains/atc.lua index 1c6df36..0cb6019 100644 --- a/advtrains/atc.lua +++ b/advtrains/atc.lua @@ -108,53 +108,49 @@ advtrains.atc_function = function(def, preset, suffix, rotation) return { after_place_node=apn_func, after_dig_node=function(pos) - return advtrains.pcall(function() - advtrains.invalidate_all_paths(pos) - advtrains.ndb.clear(pos) - local pts=minetest.pos_to_string(pos) - atc.controllers[pts]=nil - end) + advtrains.invalidate_all_paths(pos) + advtrains.ndb.clear(pos) + local pts=minetest.pos_to_string(pos) + atc.controllers[pts]=nil end, on_receive_fields = function(pos, formname, fields, player) - return advtrains.pcall(function() - if advtrains.is_protected(pos, player:get_player_name()) then - minetest.record_protection_violation(pos, player:get_player_name()) + if advtrains.is_protected(pos, player:get_player_name()) then + minetest.record_protection_violation(pos, player:get_player_name()) + return + end + local meta=minetest.get_meta(pos) + if meta then + if not fields.save then + --[[--maybe only the dropdown changed + if fields.mode then + meta:set_string("mode", idxtrans[fields.mode]) + if fields.mode=="digiline" then + meta:set_string("infotext", attrans("ATC controller, mode @1\nChannel: @2", fields.mode, meta:get_string("command")) ) + else + meta:set_string("infotext", attrans("ATC controller, mode @1\nCommand: @2", fields.mode, meta:get_string("command")) ) + end + meta:set_string("formspec", atc.get_atc_controller_formspec(pos, meta)) + end]]-- return end - local meta=minetest.get_meta(pos) - if meta then - if not fields.save then - --maybe only the dropdown changed - if fields.mode then - meta:set_string("mode", idxtrans[fields.mode]) - if fields.mode=="digiline" then - meta:set_string("infotext", attrans("ATC controller, mode @1\nChannel: @2", (fields.mode or "?"), meta:get_string("command")) ) - else - meta:set_string("infotext", attrans("ATC controller, mode @1\nCommand: @2", (fields.mode or "?"), meta:get_string("command")) ) - end - meta:set_string("formspec", atc.get_atc_controller_formspec(pos, meta)) - end - return - end - meta:set_string("mode", idxtrans[fields.mode]) - meta:set_string("command", fields.command) - meta:set_string("command_on", fields.command_on) - meta:set_string("channel", fields.channel) - if fields.mode=="digiline" then - meta:set_string("infotext", attrans("ATC controller, mode @1\nChannel: @2", (fields.mode or "?"), meta:get_string("command")) ) - else - meta:set_string("infotext", attrans("ATC controller, mode @1\nCommand: @2", (fields.mode or "?"), meta:get_string("command")) ) - end - meta:set_string("formspec", atc.get_atc_controller_formspec(pos, meta)) - - local pts=minetest.pos_to_string(pos) - local _, conns=advtrains.get_rail_info_at(pos, advtrains.all_tracktypes) - atc.controllers[pts]={command=fields.command} - if #advtrains.occ.get_trains_at(pos) > 0 then - atc.send_command(pos) - end + --meta:set_string("mode", idxtrans[fields.mode]) + meta:set_string("command", fields.command) + --meta:set_string("command_on", fields.command_on) + meta:set_string("channel", fields.channel) + --if fields.mode=="digiline" then + -- meta:set_string("infotext", attrans("ATC controller, mode @1\nChannel: @2", fields.mode, meta:get_string("command")) ) + --else + meta:set_string("infotext", attrans("ATC controller, mode @1\nCommand: @2", "-", meta:get_string("command")) ) + --end + meta:set_string("formspec", atc.get_atc_controller_formspec(pos, meta)) + + local pts=minetest.pos_to_string(pos) + local _, conns=advtrains.get_rail_info_at(pos, advtrains.all_tracktypes) + atc.controllers[pts]={command=fields.command} + if #advtrains.occ.get_trains_at(pos) > 0 then + atc.send_command(pos) end - end) + end end, advtrains = { on_train_enter = function(pos, train_id) |