diff options
-rw-r--r-- | m4/init_code.lua | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/m4/init_code.lua b/m4/init_code.lua index 5d055f0..c137758 100644 --- a/m4/init_code.lua +++ b/m4/init_code.lua @@ -95,7 +95,6 @@ function F.cpl_looparound(ln) end --end of new cpl functions - --[[ Utility Functions ]]-- F.indicator = function(indicator,set) @@ -130,12 +129,12 @@ F.has_rc_match = function(query,rc_list) -- query = pattern string, single entry if not atc_id then return false end if rc_list == "" or query == nil or query=="" then return false end if not rc_list then rc_list = F.get_rc_safe() end - + local rc = {} for v in rc_list:gmatch("("..query..")") do table.insert(rc,v) end - + if rc[1] == true then return true, rc else @@ -158,11 +157,11 @@ F.remove_rc = function(rc_list,arrow_mode) -- rc_list = string eg: "rc1 rc2 rc3" -- true: with arrow direction -- false: against arrow direction -- nil: ignores arrow direction - + if not atc_id then return false end if not rc_list then return false end - - if (arrow_mode == nil) or (atc_arrow == arrow_mode) then + + if (arrow_mode == nil) or (atc_arrow == arrow_mode) then -- prep rc_list to useable format local rc_remove = {} if type(rc_list) == "string" then @@ -174,7 +173,7 @@ F.remove_rc = function(rc_list,arrow_mode) -- rc_list = string eg: "rc1 rc2 rc3" rc_remove[word] = true end end - + -- remove codes from train's rc local rc = F.get_rc_safe() local reinsert = {} @@ -204,23 +203,23 @@ end F.yard_road_count = function(yard,section_id,monitoring_light) if not S.yards[yard][section_id] then S.yards[yard][section_id] = {['car_count'] = 0} end - + local car_count = S.yards[yard][section_id].car_count - + if event.train then if atc_arrow then --arrow points into section, add to length car_count = car_count + train_length() else -- subtract from car_count = car_count - train_length() end - + if car_count > 0 then -- light = on setstate(monitoring_light,"on") else car_count = 0 setstate(monitoring_light,"off") end - + S.yards[yard][section_id].car_count = car_count end -end
\ No newline at end of file +end |