I'm Sven, playing Factorio since 0.14 and new into modding Factorio. Until 3 weeks ago I had no clue of modding in Lua or Factorio. In the past i used many of the awesome mods here e.g. LTN, yuoki, Warehousing, ...
In Factorio i like especially the trains and I have a beauty & symmetry OCD. I started modding by dissecting community mods like yuoki's railways mod and others.
Factorio is great game with a great community - and i'd like to give something back.
![Wink ;)](./images/smilies/icon_e_wink.gif)
![Crying or Very Sad :cry:](./images/smilies/icon_cry.gif)
>>IMPORTANT:Description:
-------------------------
You love trains in Factorio? , You don't like loops?, You don't like the look/feel of dual-header trains? You have a beauty & symmetry OCD?
Then maybe Train Engineer is a mod for YOU!
With this mod you get a skilled and fully certified Train Engineer (see https://en.wikipedia.org/wiki/Railroad_engineer). After years of ative duty
Train Engineer Bob has become so skilled his actions seem like magic. He can shunt/switch trains at terminal stations without another track or locomotive.
And he works currently for free.
example for progress of events:
-------------------------------
terminal station
1) =LL-CCCCCCC============== >> train arrives at station (inbound movement)
2) =LL-CCCCCCC============== >> train waits until leave conditions are met
3) Train Engineer Bob does his magic
terminal station
4) =CCCCCCC-LL============== >> train leaves station (outbound movement)
During event 3) to 4):
- mod reads train and copies certain parameters (train composition, carriage types, cargo inventory, fuel of locomotives, loco colors, schedule)
- old train gets removed
- new train gets placed in reversed direction + parameters and inventory is inserted (a completely new train with a new Train id is created!)
Supports:
-------------------------
- different train composition LL-CCC >> CCC-LL, as long as all locos face the same direction
- fuel + cargo inventory
- schedules
- locomotive colors
- supports base game locomotive, cargo-wagon, artillery-wagon, fluid-wagon
- should support all modded loco + wagons which were derived from the base game entity types and are only modded in the entity prototype >> @me: more testing ...!
>> After every direction change train engineer performs a fuel check on every loco in the handled train. A message is given on the console @ 'fuel inventory < 10 items' and @ 'fuel inventory = 0',
the energy remaining in the burner (fuel bar) is not taken into account
Limitations:
-------------------------
>> only trains with locos facing in one direction will fire Train engineer event
>> switching trains only at stations with straight rails > no curves or diagonal rails within the length of the train allowed!
>> no cargo-wagon filters or slot filters currently supported
>> trains can not be ridden by passengers
>> trains have to be in automatic mode (mod event hooked on on_train_changed_state with with change from
'train waiting at station until leave conditions are met' to 'path lost' >> which means: single direction train at a terminal station)
>> not multiplayer tested or tested on servers!!!
>> only standard lenght wagons supported (lenght == 6), short wagons like yuoki's 'zement wagons' will fail on Train creation (displacement + not connected)
>> only fluid-wagons with 1 fluidboxes are supported
>> To Do's:
-------------------------
-- check for incompabilities with yuoki, diesel-loco, ...
-- code optimisation + cleanup
-- Train::id (uint) overflow?! what happens
-- ask in forum for help and optimization
-- big test map >> performance issues?
-- copy_settings(entity) → dictionary string → uint
-- cargo-wagon filters + blocked slots
-- maybe a seperate setting in mods gui for the remaining fuel limit message instead of the fixed 10 items
-- maybe change the fuel check to calculate the remaining MJ in a loco instead of the remaining quantity of the fuel items
-- test if LTN works
-- find out which mod adds the console message 'Warning, a train has no path to station xx' -> it's TheFatController > see ingame setup for 'train has no path'
-- mod setting to mute fuel check messages - otherwise it's spamming the console
-- test all liquids >> water + steam works so far ...
-- basic test with yuoki railway (carriages and locos) seems promising, as long as carriage lenght == 6
>> questions @ forum:
----------------------
- what happens at a Train::id overflow? is there a way to preserve the old train id?
- is there a way to safely force passengers off a train which is to be turned around and put them back into the new train?
- is there a clean way to copy settings like inventory filters or blocked slots from a source carriage to a new carriage while the source entity allready got removed via *.destroy() e.g. via a 'invisible dummy train entity'?
As I understand copy_settings() only works with two existing entities.
- in debug mode "F4" >> show-time-usage >> x/y/z >>> what stand z for? Even on a small map z goes up 'linear' to the lenght of just one test train (lenght=15) with z beyond 20++
x/y/z >> is it avg./min./max time? Z this high doesn't seems right! Can anyone point me to informations/guides on how to optimize my code / reduce the time usage?
- volunteer guinea pig to test the mod are very welcome
>> test environment:
-----------------------------
- factorio 0.16.36 win64 steam version on core i7
-----------------------------
- Backup your Saves and mods folder before use!
- use on your own risk!