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:

Re: SmartTrains 0.1.5 [WIP0.11.8+]

Post by Choumiko »

n9103 wrote: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.
Since it's only a 1 line change:

SmartTrains 0.1.6

Changes: should work for 0.11.5+, small visual changes to the UI
n9103
Smart Inserter
Smart Inserter
Posts: 1067
Joined: Wed Feb 20, 2013 12:09 am
Contact:

Re: SmartTrains 0.1.6 [0.11.5+]

Post by n9103 »

Well then, way to call me out :P
Guess I'll be giving it a go later on this week then.
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.
Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: SmartTrains 0.1.6 [0.11.5+]

Post by Choumiko »

Since the next update is going to be a while (messing with the gui, what a pain :? ) here's a little preview:
Image
This will make trains that are on the Iron East line only go to Ironmine 2 / 3 when they have less than 2k iron ore loaded (e.g. not full for a 2 wagon train), conditions for not full/empty will be added i guess.
Once that's working i really really need to start playing again. Right now i only load a save, check if the new stuff seems to work, code a little, load again :D
nosferato
Inserter
Inserter
Posts: 27
Joined: Sat Aug 02, 2014 11:11 pm
Contact:

Re: SmartTrains 0.1.6 [0.11.5+]

Post by nosferato »

Love the direction the mod is going, however I am still getting the error when upgrading from 0.1.1 to 0.1.5 or 0.1.6
""Error while running the event handler:
__SmartTrains__\control.lua:858: attempt to index field 'stGui' (a nil value)"" (taken from 0.1.6)
Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: SmartTrains 0.1.6 [0.11.5+]

Post by Choumiko »

Ok, try the attached version, should hopefully solve it for good.
Attachments
SmartTrains_0.1.7.zip
(9.56 KiB) Downloaded 210 times
nosferato
Inserter
Inserter
Posts: 27
Joined: Sat Aug 02, 2014 11:11 pm
Contact:

Re: SmartTrains 0.1.6 [0.11.5+]

Post by nosferato »

thank you, that worked great :)
now go play with the trains for awhile ;)
Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: SmartTrains 0.1.6 [0.11.5+]

Post by Choumiko »

nosferato wrote:thank you, that worked great :)
now go play with the trains for awhile ;)
Let's hope 0.1.9 still works for you :D

New version:
SmartTrains_0.1.9.zip
(12.36 KiB) Downloaded 283 times
Added dynamic lines, description in first post
User avatar
Stx3
Fast Inserter
Fast Inserter
Posts: 201
Joined: Wed Nov 05, 2014 9:04 am
Contact:

Re: SmartTrains 0.1.9 [0.11.5+]

Post by Stx3 »

fantastic mod and idea, i steal this in new hardcorio
Image
Image
Kexík
Long Handed Inserter
Long Handed Inserter
Posts: 71
Joined: Mon Dec 01, 2014 12:52 pm
Contact:

Re: SmartTrains 0.1.9 [0.11.5+]

Post by Kexík »

Awsome mod, and thx for mentioning me btw. I have question, when i use refuel option refuel station is added to train station list. Does that mean train will go there everytime, but will go through it without stop or are you controlling train manualy so train will go to station only if needed?
Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: SmartTrains 0.1.9 [0.11.5+]

Post by Choumiko »

Kexík wrote:Awsome mod, and thx for mentioning me btw. I have question, when i use refuel option refuel station is added to train station list. Does that mean train will go there everytime, but will go through it without stop or are you controlling train manualy so train will go to station only if needed?
The refueling station gets only added to the train when it's fuel is below the limit you have set in the options (default is 25 coal, 200MJ to be exact, as it compares the fuelvalue, not the itemcount). The station gets removed from the schedule when the fuelvalue is above 50 coal/400Mj (again default value), until then he goes to the refuel station everytime, waits for max. refuel time seconds or until aboe 50coal, then leaves it.
Since i know you speak lua:
Relevant code
Image
Neotix
Filter Inserter
Filter Inserter
Posts: 599
Joined: Sat Nov 23, 2013 9:56 pm
Contact:

Re: SmartTrains 0.1.9 [0.11.5+]

Post by Neotix »

I don't know why but this mod is not working in my game.

I set simple route.
Train: 5 wagons with 380 barrels each (total: 1900 barrels)
Stations:
Crude Oil Field: 30s
Refinery: 30s

In SmartTrains I have default setups.
I saved new route and set conditions:
Crude Oil Field -> Empty barrels = 1900
Refinery -> Crude Oil Barrels = 1900

So train should go to Crude Oil Field when have 1900 Empty barrels and back to Refinery with 1900 Crude Oil Barrels.
But it's not working. Trains ignore conditions and running with normal schedule. On each station I get red information about invalid condition.
Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: SmartTrains 0.1.9 [0.11.5+]

Post by Choumiko »

Neotix wrote:I don't know why but this mod is not working in my game.

I set simple route.
Train: 5 wagons with 380 barrels each (total: 1900 barrels)
Stations:
Crude Oil Field: 30s
Refinery: 30s

In SmartTrains I have default setups.
I saved new route and set conditions:
Crude Oil Field -> Empty barrels = 1900
Refinery -> Crude Oil Barrels = 1900

So train should go to Crude Oil Field when have 1900 Empty barrels and back to Refinery with 1900 Crude Oil Barrels.
But it's not working. Trains ignore conditions and running with normal schedule. On each station I get red information about invalid condition.
Tried it with 20 barrels of each type, 30s wait time and it works as intended (or as i expect it to).
I guess what you want the train to do is:
1. wait forever at the crude oil field until it is completely filled with oil barrels
2. go to the refinery
3. wait forever at the refinery until it is completely filled with empty barrels
4. go to 1.

Note the "forever". At the moment trains will never stay at a station longer than the time that is set in the schedule. The only excpetion is this:
Image
This will make your train stay forever at the refinery until it has 20 empty barrels loaded, when it has 20 loaded it will go the oil field, wait there until the time is passed or until the cargo doesn't change (if Depart is turned on) and go back to the refinery. That's probably how i would do it, since the train moves when the refinery unloaded all it's cargo, goes off to pick up the oil and returns to the refinery so it doesn't run dry.

I could add an option to the rules to stay at stations forever when all stations have a rule but none is valid. Might be a few days though
Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: SmartTrains 0.1.9 [0.11.5+]

Post by Choumiko »

It just came to me that the red message "invalid rules" is misleading in your case, perhaps "max. time reached" would be clearer? I should redo the messages at some point, so it's easier to tell what the trains are doing and why
Neotix
Filter Inserter
Filter Inserter
Posts: 599
Joined: Sat Nov 23, 2013 9:56 pm
Contact:

Re: SmartTrains 0.1.9 [0.11.5+]

Post by Neotix »

Choumiko wrote: I guess what you want the train to do is:
1. wait forever at the crude oil field until it is completely filled with oil barrels
2. go to the refinery
3. wait forever at the refinery until it is completely filled with empty barrels
4. go to 1.
Choumiko wrote: I could add an option to the rules to stay at stations forever when all stations have a rule but none is valid.
Yes, this is what I wanted to achieve and now I know why it didn't work.

There are 2 reasons why I wanted to do that:
1 - To save fuel. Trains run only at full capacity and don't waste fuel to carry empty space.
2 - To refill barrels directly in wagons. To do that I have to make 1 free slot in each wagon and when train leave station without rule, it can leave some barrels in assembly machine. With one train on route it's no problem but with two or more it eventually cause inefficiency because trains (except one) end up with all filed slots and assembly machine won't refill barrels.
gnz
Inserter
Inserter
Posts: 46
Joined: Wed Jan 14, 2015 5:19 pm
Contact:

Re: SmartTrains 0.1.9 [0.11.5+]

Post by gnz »

I'm getting really annoying errors when modifying the trains: "LuaTrain API call when the train is zero" on lines 138, 259 and 50.

I fixed this by adding a check if the train.valid is true on each of the above lines and that seems to have done the trick, however it's probably wise to fix this by doing something else as I'm probably just hiding the error.
Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: SmartTrains 0.1.9 [0.11.5+]

Post by Choumiko »

gnz wrote:I'm getting really annoying errors when modifying the trains: "LuaTrain API call when the train is zero" on lines 138, 259 and 50.

I fixed this by adding a check if the train.valid is true on each of the above lines and that seems to have done the trick, however it's probably wise to fix this by doing something else as I'm probably just hiding the error.
Modifying means adding/removing wagons/locomotives? That should only be done when the train is not in automatic mode.
Yeah, you're only hiding it, if i find the time during the weekend i'll make the trains trying to revalidate if possible. Thanks for the report ;)
gnz
Inserter
Inserter
Posts: 46
Joined: Wed Jan 14, 2015 5:19 pm
Contact:

Re: SmartTrains 0.1.9 [0.11.5+]

Post by gnz »

Choumiko wrote:
gnz wrote:I'm getting really annoying errors when modifying the trains: "LuaTrain API call when the train is zero" on lines 138, 259 and 50.

I fixed this by adding a check if the train.valid is true on each of the above lines and that seems to have done the trick, however it's probably wise to fix this by doing something else as I'm probably just hiding the error.
Modifying means adding/removing wagons/locomotives? That should only be done when the train is not in automatic mode.
Yeah, you're only hiding it, if i find the time during the weekend i'll make the trains trying to revalidate if possible. Thanks for the report ;)
This is probably related, if I try to delete a saved line then it throws the following error:

Code: Select all

__SmartTrains__/gui.lua:260: attempt to index field value '?' (a nil value)
If you are doing some changes this weekend then a way to rename lines would be much appreciated. I'm also worried about assigning my trains to lines since that would probably fill up the window space. Is it possible to add a scrollbox so I can put dynamic lines on all my train schedules?
Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: SmartTrains 0.1.9 [0.11.5+]

Post by Choumiko »

gnz wrote:This is probably related, if I try to delete a saved line then it throws the following error:

Code: Select all

__SmartTrains__/gui.lua:260: attempt to index field value '?' (a nil value)
If you are doing some changes this weekend then a way to rename lines would be much appreciated. I'm also worried about assigning my trains to lines since that would probably fill up the window space. Is it possible to add a scrollbox so I can put dynamic lines on all my train schedules?
Somehow i have the feeling you managed to mess up my way of keeping track of the trains :D
Have you upgraded from earlier versions or started the map with 0.1.9? In any case try using /c remote.call("st", "hardReset", true) in the console. You will loose all your train lines and settings (refuel station etc) but if it was an error due to upgrading it should help.

Scrollbox is not possible, but in the version i'm working on, i already have it create pages when there's more than 5 lines/stations.
gnz
Inserter
Inserter
Posts: 46
Joined: Wed Jan 14, 2015 5:19 pm
Contact:

Re: SmartTrains 0.1.9 [0.11.5+]

Post by gnz »

Choumiko wrote: Somehow i have the feeling you managed to mess up my way of keeping track of the trains :D
Have you upgraded from earlier versions or started the map with 0.1.9? In any case try using /c remote.call("st", "hardReset", true) in the console. You will loose all your train lines and settings (refuel station etc) but if it was an error due to upgrading it should help.
I had tried that before and it came back, but just for sake of sanity I removed my changes and started up the game. Did the hardreset and tried creating lines and deleting them. Most of the time it worked as intended but once it threw the same error. Probably related to removing invalid lines more often though so I'll look forward to the next release instead and for now expand my base with more stations and mini bases.
Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: SmartTrains 0.1.9 [0.11.5+]

Post by Choumiko »

SmartTrains_0.2.0.zip
(13.33 KiB) Downloaded 1018 times
Changes:
- rename lines
- pagination for train lines, rules, train schedules (for now hardcoded to 5 per page)
- option to make trains wait forever when there are only invalid rules on their line (global setting for all trains, autodepart still has to be on for it to work)
- catching more errors with invalid trains
- global settings /rules close other windows, reopen on save
- train lines can be edited/renamed/deleted when train stop ui is open

This version will not upgrade from versions < 0.1.9, so make a save with 0.1.9 first if you're still using an older one (or disable the mod, save the game, update the mod and enable it)

I need to rewrite big parts before adding anything new, as the code is getting really messy (this mod is the result of me learning modding/lua, so.. yeah ;) )
The "wait forever" feature should really be another rule for lines, but in the way of "leave station when item x above/below/equal y amount".
Post Reply

Return to “Mods”