diff options
Diffstat (limited to 'Tyard/init_code.lua')
-rw-r--r-- | Tyard/init_code.lua | 46 |
1 files changed, 13 insertions, 33 deletions
diff --git a/Tyard/init_code.lua b/Tyard/init_code.lua index 9b21432..fe220da 100644 --- a/Tyard/init_code.lua +++ b/Tyard/init_code.lua @@ -33,6 +33,7 @@ F.has_rc = function(query,rc_list) -- query eg: "rc1" for word in rc_list:gmatch("[^%s]+") do if word == query then return true end end + print(F.get_rc_safe()) return false end @@ -62,47 +63,26 @@ F.remove_rc = function(rc_list,arrow_mode) -- rc_list eg: {"rc1","rc2"} -- insert new string to train's rc set_rc(table.concat(reinsert," ")) end + print(F.get_rc_safe()) return reinsert end +F.remove_rc_match = function(rc_list) -- rc_list eg: "rc_%d+" + local rm = {} + for v in F.get_rc_safe():gmatch("("..rc_list..")") do + table.insert(rm,v) + end + F.remove_rc(rm) + print(F.get_rc_safe()) + return rm +end + F.add_rc = function(rc_list) -- rc_list eg {"rc1","rc2"} OR "rc1 rc2" if not atc_id then return false end if type(rc_list) == "table" then rc_list = table.concat(rc_list," ") end set_rc(F.get_rc_safe().." "..rc_list) + print(F.get_rc_safe()) return true end - --- EOL function -F.EOL = function(this_dir) - -- this_dir == true for north end, false for south end - if not F.yard_active() then return end - if atc_arrow then - if F.dir() == this_dir then --train has bounced and needs to leave the rake or depart with it - if F.has_rc("TY_FINAL_COLLECT") then -- take the whole rake to the exit - F.remove({"TY_FINAL_COLLECT"}) - F.add_rc({"TY_DEPART"}) - else -- disconnect loco and return to pickup - split_off_locomotive("A0B0") - F.add_rc({"TY_PICKUP"}) - end - F.add_rc({"TY_HEADSHUNT"}) - else --train needs to bounce - atc_send("B0WRD1S4") - end - else - if F.dir() == this_dir then - --train is clasifying wagons, let it pass and couple to the rest of the rake - local rm = {} - for v in F.get_rc_safe():gmatch("(TY_CLASS_%S-)") do - table.insert(rm,v) - end - F.remove_rc(rm) - else --this should never come into play as it means the train has entered from the wrong end somehow - atc_send("BBOL") --stop the train and open the doors (if available) to signify assistance required - F.error(true) - end - end -end - |