SmartTrains 0.2.0 [0.11.5+]

Topics and discussion about specific mods
Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

SmartTrains 0.2.0 [0.11.5+]

Post by Choumiko »

Current features:
  • Trainlines:
    Saving of train schedules as a line, assign trains to lines. Trains update their schedule at a station when it's line changed
    Dynamic lines:You can set conditions for stations on a trainline. If the cargo in the train does not match the condition it will skip the station
  • Autorefuel/Autodepart:
    Trains add a refueling station to the schedule when fuel is below a certain value, then leave and remove it when fuel is above a value
    Trains leave stations when there is no change in their loaded cargo for a certain time (2s interval as default, cargo difference is checked per item)
    maximum time still is the time set in the schedule
    minimum waiting time (4s as default, change it in the global settings window)
  • UI to toggle Autorefuel and Autodepart per train (opens when you open the standard train UI)
  • UI for Autorefuel/-depart settings (Button "ST" at the top left corner when train or train-stop gui is open)
  • Works with Rail Tanker (Rail Tanker 0.0.8+)
Latest version: SmartTrains 0.2.0

Credits to:
rk84 (Test mode) code/styles for the dynamic rules are from him. Test mode gui used as a source for learning factorio gui
Kexik (AlphaMod) code for liquid items taken from his source
JamesOFarrell (RailTanker, Fat Controller) also a source for gui learning, some code for tracking trains and stuff

Upgrading should be painless, but i'd advise you to backup the save anyways, you never know :?
For versions > 0.1.0: If it doesn't work: look into the folder "(Factorio)/script-output/st/" there should be some files named debugGlob*.lua Would be really helpfull if you could post them here.
If you're not worried about loosing your SmartTrains settings look at the console commands

Current issues :
  • Making changes to the train schedule with the vanilla UI should be done when the train is in manualmode and has no active line, else he could decide that he doesn't like the changes and revert them ;)
    I see no way around that for now. Changing the active line, refuel, depart settings while automated works.
  • "Jumpy" gui: Sometimes the schedule overview changes places, mostly when changing active line, reading from ui.
  • There might be some side effects between autorefuel, autodepart and dynamic rules. If something seems strange, please report it, could be working as intended or a bug
A quick howto on trainlines:
  • Creating a line: Stop the train, change the schedule as you wish, click "Read from UI", name the line, hit "Save as line", start the train. Done. The train is then automatically assigned to this line.
  • Changing a line: Like creating a line, when hiting "Read from UI" the train is unassigned from it's current line. The train your saving the line on get's updated right away, all other trains update at the next station they are going to
  • When you delete a line which has trains assigned, the trains delete their line and just keep the schedule
Dynamic lines: When you have a line setup, you'll see a new button "Rules" in the line window. Click it to set rules for the line.
The items you want to set conditions for should be in your hotbar. To set an item put it on your cursor and click in the grey box, to unset it, click with it with no item on the cursor
ImageImageImageImage
From left to right:
  • Train goes to Ore unload only if it has more than 2k iron ore loaded, else it goes to Mine 1,2,3
  • Same as before, but only goes to Mine3 when cargo <= 1500 (e.g. because it's way off)
  • This line will have its trains waiting at Ore unload until iron-ore is < 1, ignoring the time that is set in the schedule Edit: I just noticed that this example only makes sense if using only 1 Mining station
  • Yes, rules for liquids too (only usefull when using Rail Tanker) Get the items into your inventory by clicking "Liquid items"
Note: If every station in a line has a condition set and none of them is true, the train will ignore the conditions and go from station to station and check again at every station. If all but one station has a condition set (like in the 3rd picture) and all fail the train will stay at the station without the condition)
Console commands
Changelog
Last edited by Choumiko on Wed Feb 04, 2015 10:56 am, edited 13 times in total.

G_glop
Long Handed Inserter
Long Handed Inserter
Posts: 72
Joined: Thu Dec 18, 2014 1:29 pm
Contact:

Re: [MOD 0.11.6][WIP] SmartTrains

Post by G_glop »

Maybe you coud make a smart train stantion that woud accept the train only of certain circuit netowork condicions were met, and some kind of circuit network broadcaster/reciver to do something like this, if coal(in main base) < 2000 then activate train stantion with coal(coal outopost)

Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: [MOD 0.11.6][WIP] SmartTrains

Post by Choumiko »

G_glop wrote:Maybe you coud make a smart train stantion that woud accept the train only of certain circuit netowork condicions were met, and some kind of circuit network broadcaster/reciver to do something like this, if coal(in main base) < 2000 then activate train stantion with coal(coal outopost)
Sounds interesting enough, maybe this will be easier/quicker to implement when 0.12 adds new circuit stuff. THis might also make Railyards a reasonable thing to build, trains that don't have "jobs" park there to not clog stations for other trains. Oh my, i can see this mod getting way to complicated if i don't hold back. Right now i need to clean up the code before i addd anything new, as it's starting to get messy.

Also: new version with gui in the OP.

G_glop
Long Handed Inserter
Long Handed Inserter
Posts: 72
Joined: Thu Dec 18, 2014 1:29 pm
Contact:

Re: [MOD 0.11.6][WIP] SmartTrains

Post by G_glop »

Choumiko wrote:
G_glop wrote:Maybe you coud make a smart train stantion that woud accept the train only of certain circuit netowork condicions were met, and some kind of circuit network broadcaster/reciver to do something like this, if coal(in main base) < 2000 then activate train stantion with coal(coal outopost)
Sounds interesting enough, maybe this will be easier/quicker to implement when 0.12 adds new circuit stuff. THis might also make Railyards a reasonable thing to build, trains that don't have "jobs" park there to not clog stations for other trains. Oh my, i can see this mod getting way to complicated if i don't hold back. Right now i need to clean up the code before i addd anything new, as it's starting to get messy.

Also: new version with gui in the OP.
Okay, the broadcaster/reciver is for wireless circuit network connection(not having to run km of wires)

User avatar
SHiRKiT
Filter Inserter
Filter Inserter
Posts: 706
Joined: Mon Jul 14, 2014 11:52 pm
Contact:

Re: SmartTrains 0.0.2 [WIP0.11.8]

Post by SHiRKiT »

How come I missed this mod? Woah, thanks!

Telarin
Long Handed Inserter
Long Handed Inserter
Posts: 62
Joined: Tue Mar 05, 2013 2:17 pm
Contact:

Re: SmartTrains 0.0.2 [WIP0.11.8]

Post by Telarin »

I am getting the following error after playing for a while with this mod:

Notice

Error while running the event handler:
__SmartTrains__\control.lua:243: attempt to index field '?' (a nil value)

And then the game crashes and must be restarted. The error now occurs consistently after a few seconds when I load this save, so I have had to disable this mod :(

Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: SmartTrains 0.0.2 [WIP0.11.8]

Post by Choumiko »

Telarin wrote:I am getting the following error after playing for a while with this mod:

Notice

Error while running the event handler:
__SmartTrains__\control.lua:243: attempt to index field '?' (a nil value)

And then the game crashes and must be restarted. The error now occurs consistently after a few seconds when I load this save, so I have had to disable this mod :(
Are you using the latest version? Because line 243 there doesn't make any sense to me, as it's only "end". If you're using the latest version i'd aprecciate if you could upload the save. I'm currently looking for ways to produce better error messages and/or avoid them, as i had lots of trouble when testing 0.0.2 on a savegame with my first release. Same errors like yours, seems like i haven't catched them all :roll: Sorry about that.

Edit: Have you tried reenabling the mod after you saved with the mod disabled? This should have removed the old data from the savefile. Your trains then should get "smart" again after they arrive at a station for the first time

User avatar
Dariel92
Inserter
Inserter
Posts: 41
Joined: Mon Aug 25, 2014 1:25 pm
Contact:

Re: SmartTrains 0.0.2 [WIP0.11.8]

Post by Dariel92 »

RU: У меня вылетает ошибка после загрузки игры, хотя я только начал по новой и даже не выучил поездов. Вот скрин ошибки
EN: I fly error after loading the game, although I just started on a new and even learned trains. Here is a screen of the error
Attachments
ошибка.jpg
ошибка.jpg (152.63 KiB) Viewed 24133 times

Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: SmartTrains 0.0.2 [WIP0.11.8]

Post by Choumiko »

Dariel92 wrote:EN: I fly error after loading the game, although I just started on a new and even learned trains. Here is a screen of the error
Should be gone with version 0.1.0 which i uploaded just now :)
If it still doesn't work, i need a list of the mods you are using

Changes:
  • Autodepart now has a minimum waiting time (set for all trains for now), this is the time the train waits even if there is no change in the cargo
  • Cargo is now checked per item, the train only leaves early if no item got loaded/unloaded
  • Gui only visible when train schedule or train stop gui is opened
That's all for now.

A few ideas i'd like feedback to: Should i make the currently global settings changeable per train, and/or make the waiting times/check intervals also dependent on the station? I have not thought about uses for this, just got the idea when adding the gui to the station.
Any other ideas/improvements are also welcome.
Next thing i'll try to add is conditional stations, e.g. Train only goes to a station when the trains cargo is above/below a certain value. Schedule would be for example: Iron Mining Station -> Factory -> Storage. The Storage station would only be added if the cargo of the train is above a certain value, else it would go back to the mining station.

Telarin
Long Handed Inserter
Long Handed Inserter
Posts: 62
Joined: Tue Mar 05, 2013 2:17 pm
Contact:

Re: SmartTrains 0.1.0 [WIP0.11.8]

Post by Telarin »

Apologies, I had not seen the 0.1.0 update and was still running 0.0.1. When I updated, the error I reported earlier went away.

nosferato
Inserter
Inserter
Posts: 27
Joined: Sat Aug 02, 2014 11:11 pm
Contact:

Re: SmartTrains 0.1.0 [WIP0.11.8]

Post by nosferato »

I am getting this error with version 0.1.0
"Error while running the event handler:
__SmartTrains__\control.lua:460: attempt to index field 'stGui' (a nil value)"

only have rail tanker mod installed within an existing world,
I have removed all trains and stations and still getting the error
doesn't throw the error on a newly generated world

Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: SmartTrains 0.1.0 [WIP0.11.8]

Post by Choumiko »

Thanks for the report, sadly i wasn't able to reproduce it. Try the attached zip to see if it helps.
Have you been using an earlier version of the mod on the save before?

There's gonna be a new version out today anyways, which hopefully will upgrade without problems from 0.1.0/0.1.1
I'm currently testing it with all different saves (vanilla, v0.1.0, etc)
Attachments
SmartTrains_0.1.1.zip
(5.89 KiB) Downloaded 215 times

Telarin
Long Handed Inserter
Long Handed Inserter
Posts: 62
Joined: Tue Mar 05, 2013 2:17 pm
Contact:

Re: SmartTrains 0.1.0 [WIP0.11.8]

Post by Telarin »

Not sure if this is addressed in 0.1.1 yet, as I'm still running 0.1.0, but I have encountered a small issue. I have several trains that seem to "share" settings. What I mean is that if I turn auto depart or refuel on or off on certain trains, it turns it on/off on other trains as well. Not ALL trains share settings, just particular ones. The trains sharing settings all have different names.

Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: SmartTrains 0.1.0 [WIP0.11.8]

Post by Choumiko »

Telarin wrote:Not sure if this is addressed in 0.1.1 yet, as I'm still running 0.1.0, but I have encountered a small issue. I have several trains that seem to "share" settings. What I mean is that if I turn auto depart or refuel on or off on certain trains, it turns it on/off on other trains as well. Not ALL trains share settings, just particular ones. The trains sharing settings all have different names.
It's not fixed in 0.1.1 but in the next release it will be.
Hope your finding it useful still, i can't tell because i have so much fun with coding this mod i haven't gotten to use it in a real save :D

nosferato
Inserter
Inserter
Posts: 27
Joined: Sat Aug 02, 2014 11:11 pm
Contact:

Re: SmartTrains 0.1.0 [WIP0.11.8]

Post by nosferato »

i had tried an earlier version of the mod, but it caused issues, and i decided to wait for a gui

nosferato
Inserter
Inserter
Posts: 27
Joined: Sat Aug 02, 2014 11:11 pm
Contact:

Re: SmartTrains 0.1.0 [WIP0.11.8]

Post by nosferato »

This version works, I did delete the cache before trying this version, so that could also have fixed it.

I have placed down stations for Coal Loading, Coal Unloading and Refuel. put down a train and gave it a schedule of Coal Loading to Unloading, and gave the train 2 coal in each engine. now i get the error
__SmartTrains__\control.lua:423 attempt to perform arithmetic on field 'lastCheck' (a boolean value)

Never Mind, it looks as though the error was caused by no viable route between stations

n9103
Smart Inserter
Smart Inserter
Posts: 1067
Joined: Wed Feb 20, 2013 12:09 am
Contact:

Re: SmartTrains 0.1.0 [WIP0.11.8]

Post by n9103 »

I, for one, *love* this mod.
Replaced Fat Controller for be train mod, since this is programmable (less micromanagement), and a little less OP (not unlimited range). Though I did love being able to look at exactly what my train was doing, it was a bit too powerful since it was all times. Would love to see a Control Station or something that combined the two functions though. Maybe something official in the post .12.X experimental cycle? :)
Colonel Failure wrote:You can lose your Ecologist Badge quite quickly once you get to the point of just being able to murder them willy-nilly without a second care in the world.

nosferato
Inserter
Inserter
Posts: 27
Joined: Sat Aug 02, 2014 11:11 pm
Contact:

Re: SmartTrains 0.1.0 [WIP0.11.8]

Post by nosferato »

After successfully having my trains running, I have noted changes to the rail system that does invoke an invalid route does cause the error
"__SmartTrains__\control.lua:423 attempt to perform arithmetic on field 'lastCheck' (a boolean value)"

Otherwise is a great mod

Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: SmartTrains 0.1.0 [WIP0.11.8]

Post by Choumiko »

nosferato wrote:I have noted changes to the rail system that does invoke an invalid route does cause the error
"__SmartTrains__\control.lua:423 attempt to perform arithmetic on field 'lastCheck' (a boolean value)"
Otherwise is a great mod
Fixed in 0.1.5 and thanks ;)
n9103 wrote:I, for one, *love* this mod.
Replaced Fat Controller for be train mod, since this is programmable (less micromanagement), and a little less OP (not unlimited range). Though I did love being able to look at exactly what my train was doing, it was a bit too powerful since it was all times. Would love to see a Control Station or something that combined the two functions though. Maybe something official in the post .12.X experimental cycle? :)
With train lines in my new version, i'm interested to know whether you think they are OP :D I guess when i add more features i really should add a building and/or tech. But graphics, can't do that :?: :lol:
I use FatController mostly as an onboard camera, simply enjoying the ride, i very rarely change the schedule of a train with it.

New version : 0.1.5
Changes:
  • Added styles for the gui
  • Autodepart with rail tanker wagons when liquid flow < 1/s (configure in ui)
  • Trains leave refuel station when fuel above configured limit
  • console commands for hard reset, displaying additional info
  • Train lines (see first post for details)

n9103
Smart Inserter
Smart Inserter
Posts: 1067
Joined: Wed Feb 20, 2013 12:09 am
Contact:

Re: SmartTrains 0.1.5 [WIP0.11.8+]

Post by n9103 »

It's going to be awhile, since I'm in the middle of an old version's game (.11.5) but I'll chime in when I do decide to update.
Colonel Failure wrote:You can lose your Ecologist Badge quite quickly once you get to the point of just being able to murder them willy-nilly without a second care in the world.

Post Reply

Return to “Mods”