summaryrefslogtreecommitdiff
path: root/m4/init_code.lua
diff options
context:
space:
mode:
Diffstat (limited to 'm4/init_code.lua')
-rw-r--r--m4/init_code.lua23
1 files changed, 16 insertions, 7 deletions
diff --git a/m4/init_code.lua b/m4/init_code.lua
index d32be9f..65e58bb 100644
--- a/m4/init_code.lua
+++ b/m4/init_code.lua
@@ -53,33 +53,36 @@ function F.cpllooparound(ln)
end
--new ones
+--these work with train going forward with engine in front! :D
function F.split_looparound(ln)
if not (event.train) then return end
if not (F.get_line_safe() == ln) then return end
+ if not (F.get_train_length_safe() >= 2) then return end -- no wagons? do nothing! :D
- split_at_index(F.get_train_length_safe()-1,"A0S0OC") --Stopping the wagons is handled here by SO
+ --split_at_index(F.get_train_length_safe()-1,"A0S0OC") --Stopping the wagons is handled here by SO
+ split_at_index(2,"A0S0OC") --Stopping the wagons is handled here by SO
set_rc("ENGINE")
atc_send("A1")
-
end
function F.split_looparound_left(ln)
if not (event.train) then return end
if not (F.get_line_safe() == ln) then return end
+ if not (F.get_train_length_safe() >= 2) then return end -- no wagons? do nothing! :D
- split_at_index(F.get_train_length_safe()-1,"A0S0OL") --Stopping the wagons is handled here by SO
+ split_at_index(2,"A0S0OL") --Stopping the wagons is handled here by SO
set_rc("ENGINE")
atc_send("A1")
-
end
+
function F.split_looparound_right(ln)
if not (event.train) then return end
if not (F.get_line_safe() == ln) then return end
+ if not (F.get_train_length_safe() >= 2) then return end -- no wagons? do nothing! :D
- split_at_index(F.get_train_length_safe()-1,"A0S0OR") --Stopping the wagons is handled here by SO
+ split_at_index(2,"A0S0OR") --Stopping the wagons is handled here by SO
set_rc("ENGINE")
atc_send("A1")
-
end
function F.cpl_looparound(ln)
@@ -91,10 +94,16 @@ function F.cpl_looparound(ln)
set_rc("")
return
end
-
end
--end of new cpl functions
+--[[ testing functions for train length print
+]]--
+function F.print_length()
+ F.print(F.get_train_length_safe())
+end
+
+
--[[ Utility Functions
]]--
F.indicator = function(indicator,set)