[MOD 0.15] SmartTrains 2.0.5

Topics and discussion about specific mods
wahming
Fast Inserter
Fast Inserter
Posts: 190
Joined: Sun May 17, 2015 8:30 pm
Contact:

Re: [MOD 0.12.30+] SmartTrains 0.3.82

Post by wahming »

What does the depart checkbox actually do, in the train lines summary?

User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: [MOD 0.12.30+] SmartTrains 0.3.82

Post by siggboy »

wahming wrote:What does the depart checkbox actually do, in the train lines summary?
If you have it checked, it will make the trains leave a station if their cargo has not changed for a few seconds (or if it only changes very slowly). So you can have the trains leave the outposts as soon as they have emptied the buffer at the outpost.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick

wahming
Fast Inserter
Fast Inserter
Posts: 190
Joined: Sun May 17, 2015 8:30 pm
Contact:

Re: [MOD 0.12.30+] SmartTrains 0.3.82

Post by wahming »

siggboy wrote:
wahming wrote:What does the depart checkbox actually do, in the train lines summary?
If you have it checked, it will make the trains leave a station if their cargo has not changed for a few seconds (or if it only changes very slowly). So you can have the trains leave the outposts as soon as they have emptied the buffer at the outpost.
Oh joy. That's just what I needed :D

GodricSeer
Inserter
Inserter
Posts: 30
Joined: Fri May 06, 2016 2:01 pm
Contact:

Re: [MOD 0.12.30+] SmartTrains 0.3.82

Post by GodricSeer »

I have found an incompatibility between this and Hard Crafting 0.3.10. I understand these mods don't say explicitly that they are compatible with each other, but wanted to point it out anyways.

For some reason when Hard crafting is attempting to add a scrap metal result to the smart train stop recipe, it changes the output of the smart train stop recipe outputs a train stop rather than a smart train stop.

I think what is happening is that Hard Crafting is changing the train stop recipe prior to the smart train stop recipe being created and then the copyPrototype function isn't liking the two outputs when it tries to create the updated recipe.

User avatar
MrGrim
Fast Inserter
Fast Inserter
Posts: 232
Joined: Sat Apr 09, 2016 7:58 pm
Contact:

Re: [MOD 0.12.30+] SmartTrains 0.3.82

Post by MrGrim »

I have found a bug that is only exposed if another mod makes a specific type of change to recipes prior to this mod running. It's in the the "copyPrototype" function in lib.lua. The problem is if a mod that loads prior to SmartTrains modifies a recipe later modified by SmartTrains with this function to use the table "results" rather than the "result" value then the result is never modified as expected. This manifest as, for example, the recipe for the smart train station to retain the result of only a normal train stop plus whichever results the earlier mod added to the results table.

An example of such a mod is Hard Crafting (viewtopic.php?f=91&t=18877) which modifies several recipes to include scrap metal as a result. Specifically you can look at the file "prototypes/harder-buildings.lua" to see what it does.

The following addition to the copyPrototype function before the return statement is enough to make SmartTrains more resilient to such prior modifications:

Code: Select all

  if p.results then
    for i = 1, #p.results do
	  if p.results[i].name == name then
	    p.results[i].name = newName
	  end
	  
	  if p.results[i][1] == name then
	    p.results[i][1] = newName
      end
	end
  end
Now, for some odd reason the Hard Crafting author modifies several unrelated aspects of recipes in that function that adds scrap including the icons if they're not already defined which breaks the recipe icon for the Smart Trains stop. I'm going to report that as a bug over there.

Thanks for the great mod!

**EDIT: Or I could have just read GodricSeer's message and elaborated.. :D

**EDIT 2:

I found out why the icons modification! The icon, subgroup, and order are implicit with a single result recipe that has no results table! So, in that case things start to get a little more ambiguous, but I think the following is a pretty safe assumption for the most part:

Code: Select all

  if p.results then
    for i = 1, #p.results do
	  if p.results[i].name == name then
	    p.results[i].name = newName
	  end
	  
	  if p.results[i][1] == name then
	    p.results[i][1] = newName
      end
	end
	
	if type == "recipe" then
      p.icon = data.raw["item"][newName].icon
	  p.subgroup = data.raw["item"][newName].subgroup
      p.order = data.raw["item"][newName].order
	end
  end
However, for this method to work the replacement item must be added to data.raw first! So, in "smart_train_stop.lua" line 37 needs to be changed to:

Code: Select all

data:extend({smart_train_stop,recipe, st_proxy, st_proxy_i,})
Then the following added between lines 3 and 5:

Code: Select all

data:extend({item})

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

Re: [MOD 0.12.30+] SmartTrains 0.3.82

Post by Choumiko »

Updated to SmartTrains 0.3.95
(Same as the latest prerelease)

For changes take a look at the release notes in the link.
This will probably be the last version for 0.12.x. 0.13 brings so many changes to the trainsystem i want for SmartTrains.

User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: [MOD 0.12.30+] SmartTrains 0.3.95

Post by siggboy »

Here's two problems that I've found in 0.3.94:

1. Train lines sometimes don't get updated. I'm adding a station to the line and set the wait time to "infinite", but the train line never gets updated (the station is in the line, but the wait time stays at the default). In some cases I was able to force an update by removing the train from the line and then adding it back; in other cases this did not work.

2. Trains are sitting at a signal forever. This has happened in cases where the train was set to leave "empty & signal", and also in cases where the condition was just ("signal"). The signal lamp was green, the other conditions were true as well, but the train did not leave the station, instead sitting at the green signal forever. This problem appears sporadically and I have found no way to reproduce it.

Sorry that I don't have more information, I could give you a save file of the actual game when it happens again.

Maybe looking at the respective code in the mod will be enough already.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick

Bizobinator
Fast Inserter
Fast Inserter
Posts: 193
Joined: Fri May 06, 2016 10:35 pm
Contact:

Re: [MOD 0.12.30+] SmartTrains 0.3.95

Post by Bizobinator »

Choumiko wrote:Updated to SmartTrains 0.3.95
(Same as the latest prerelease)

For changes take a look at the release notes in the link.
This will probably be the last version for 0.12.x. 0.13 brings so many changes to the trainsystem i want for SmartTrains.
I take it that 0.3.95 doesn't work in 0.13.x? :(

xmnovotny
Burner Inserter
Burner Inserter
Posts: 18
Joined: Wed Jun 29, 2016 7:47 am
Contact:

Re: [MOD 0.12.30+] SmartTrains 0.3.95

Post by xmnovotny »

I have reworked the code of this mod for version 0.13, (just for myself - I couldn't wait for the author's update :-) ). It basically works, but it's not ideal.

If someone wants my version before Choumiko releases the new version, I can post a download link here.
And I can also make a pull request with my changes, if Choumiko is interested.

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

Re: [MOD 0.12.30+] SmartTrains 0.3.95

Post by Choumiko »

xmnovotny wrote:I have reworked the code of this mod for version 0.13, (just for myself - I couldn't wait for the author's update :-) ). It basically works, but it's not ideal.

If someone wants my version before Choumiko releases the new version, I can post a download link here.
And I can also make a pull request with my changes, if Choumiko is interested.
Just for curiosity, make a pull request. I will not accept it though, since i'm close to finishing the update :D

floodo1
Inserter
Inserter
Posts: 21
Joined: Tue Jun 28, 2016 2:33 am
Contact:

Re: [MOD 0.12.30+] SmartTrains 0.3.95

Post by floodo1 »

exciting stuff. Going to be awesome to have my smart train networks working in the 0.13 world ... really looking forward to watching my train network run with the new faster inserters and larger cargo wagons! Can the rail tankers keep up?!?!?!? :D

User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: [MOD 0.12.30+] SmartTrains 0.3.95

Post by siggboy »

Choumiko wrote:Just for curiosity, make a pull request. I will not accept it though, since i'm close to finishing the update :D
What about the other mods (FARL, FatController)? Is there a 0.13 roadmap for these as well? Will you update SmallFixes?

I'll test the heck out of SmartTrains in 0.13 as soon as we get a working TestMode (or ToyBox), because without those it's too unfun to develop in sandboxes.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick

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

Re: [MOD 0.12.30+] SmartTrains 0.3.95

Post by Choumiko »

siggboy wrote:What about the other mods (FARL, FatController)? Is there a 0.13 roadmap for these as well? Will you update SmallFixes?

I'll test the heck out of SmartTrains in 0.13 as soon as we get a working TestMode (or ToyBox), because without those it's too unfun to develop in sandboxes.
All mods except SmartTrains are updated :D

for testmode like behaviour: /c game.player.cheat_mode = true; game.player.force.research_all_technologies()
Let's you craft without ingredients.

Right now i'm struggling a bit with making updating trainlines work correctly. Everything else should be working, except Railtankers, if you want full/empty rules with these you have to resort to using a circuit condition and check full/empty yourself. But i think it's really worth it, since on_tick is only needed to update the cargo combinator and do the autorefuel checks for trains that are currently refueling.

User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: [MOD 0.12.30+] SmartTrains 0.3.95

Post by siggboy »

Choumiko wrote:All mods except SmartTrains are updated :D
Just amazing how fast you are. I've also realized that some of my most loved mods (module inserter, auto trash) are also made by you, didn't even know that. Already updated of course.

Thanks a lot for all the good stuff (can't be said often enough I guess).

Still I NEED SmartTrains or else the game is boring for me :). So I'll have to wait for that release before updating to 0.13.
for testmode like behaviour: /c game.player.cheat_mode = true; game.player.force.research_all_technologies()
Let's you craft without ingredients.
That's very useful, thanks. I've also seen a post somewhere where somebody showed a LUA fragment that would make all your logistic requests complete automatically (like cheat mode, but even more convenient).
Right now i'm struggling a bit with making updating trainlines work correctly. Everything else should be working, except Railtankers, if you want full/empty rules with these you have to resort to using a circuit condition and check full/empty yourself. But i think it's really worth it, since on_tick is only needed to update the cargo combinator and do the autorefuel checks for trains that are currently refueling.
Checking full/empty from a circuit is super easy if you know what cargo you're dealing with (if it's only Oil in the Rail Tanker, then it's straightforward). If you don't know the cargo, then you might have to first subtract all the other signals that might appear in the combinator (like train-at-station, fuel-level etc.) and filter only positive values before you get a signal that only contains the cargo.

So it can be awkward if you need to make a cargo check yourself (what about that "train-full" signal from the combinator? :) )
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick

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

Re: [MOD 0.12.30+] SmartTrains 0.3.95

Post by Choumiko »

siggboy wrote:Checking full/empty from a circuit is super easy if you know what cargo you're dealing with (if it's only Oil in the Rail Tanker, then it's straightforward). If you don't know the cargo, then you might have to first subtract all the other signals that might appear in the combinator (like train-at-station, fuel-level etc.) and filter only positive values before you get a signal that only contains the cargo.

So it can be awkward if you need to make a cargo check yourself (what about that "train-full" signal from the combinator? :) )
I sort of made up my mind about Railtanker: The latest update keeps the fake items in the tanker. That way the vanilla conditions work with railtanker too :D Only downside is that inserters are able to take the items out..
"train full" signal and the other rules are probably not going to happen in 0.13, reason is: SmartTrains no longer checks the rules, it's all done by Factorio itself. Factorio only stores the expected departure time once a train arrives at a station. Then if the train leaves before that, it assumes that a condition became true and looks up the circuit value to make jumpTo rules work. So all it knows is that _some_ condition became true, could be full/empty/inactivity/signal etc.. So that's the only thing i could output, whether the train left due to time or any condition.

Prerelease probably in the next 3-5 hours, depending on how long Germany needs to beat Italy :mrgreen:

User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: [MOD 0.12.30+] SmartTrains 0.3.95

Post by siggboy »

Choumiko wrote:I sort of made up my mind about Railtanker: The latest update keeps the fake items in the tanker. That way the vanilla conditions work with railtanker too :D Only downside is that inserters are able to take the items out..
I just had to go to the Railtanker thread to see what you mean by that. It's indeed a bit ugly, but probably no good way to avoid having it. On the other hand we'll probably get the official tanker wagon in 0.13 anyway, then the mod will be entirely obsolete. I'm currently not using it because barrels are a bit more interesting to play with and slightly faster when you need to move large amounts of oil quickly. Is it still possible to reliably connect 4 pumpts to a wagon? Because that's kind of necessary to get acceptable loading/unloading times out of the tanker (20 seconds instead of 40 for a full wagon).
"train full" signal and the other rules are probably not going to happen in 0.13, reason is: SmartTrains no longer checks the rules, it's all done by Factorio itself. Factorio only stores the expected departure time once a train arrives at a station. Then if the train leaves before that, it assumes that a condition became true and looks up the circuit value to make jumpTo rules work. So all it knows is that _some_ condition became true, could be full/empty/inactivity/signal etc.. So that's the only thing i could output, whether the train left due to time or any condition.
I guess that's fine, since it really seems to make things simpler and faster (probably a lot faster). In my current game (with my scheduler) I check the cargo manually everywhere, so I have control over how much the train will load before it leaves from the circuit side (and I need that because the circuit tells the receiving station how much cargo is incoming). To that end it's completely sufficient how things work right now, with the combinator updating the cargo every few ticks. It's just that you need 2 combinators to filter the SmartTrains signals first, so you get a "clean" wire with only the cargo signal on it (otherwise you can't use "wildcard" conditions on the cargo, which you kind of need if you make a generic circuit that works independent of the cargo type).

Probably in 0.13 it would be easier to read the cargo directly from the station, that would solve that problem anyway (I'm not sure right now if that's already possible or only planned for a future patch).

I'd still very much like to be able to read the station number from the station directly (as discussed before in the "combinator magick" thread). And what about the "pulse" signal when the train leaves (maybe with the number of the next destination as a value)? Is that going to be possible?
Prerelease probably in the next 3-5 hours, depending on how long Germany needs to beat Italy :mrgreen:
Yeah, I'm watching it, too (I'm German myself :) ). First half pretty much as expected, with everybody playing it safe. I really hope you're right and they finally win against Italy.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick

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

Re: [MOD 0.12.30+] SmartTrains 0.3.95

Post by Choumiko »

siggboy wrote:I guess that's fine, since it really seems to make things simpler and faster (probably a lot faster). In my current game (with my scheduler) I check the cargo manually everywhere, so I have control over how much the train will load before it leaves from the circuit side (and I need that because the circuit tells the receiving station how much cargo is incoming). To that end it's completely sufficient how things work right now, with the combinator updating the cargo every few ticks. It's just that you need 2 combinators to filter the SmartTrains signals first, so you get a "clean" wire with only the cargo signal on it (otherwise you can't use "wildcard" conditions on the cargo, which you kind of need if you make a generic circuit that works independent of the cargo type).

Probably in 0.13 it would be easier to read the cargo directly from the station, that would solve that problem anyway (I'm not sure right now if that's already possible or only planned for a future patch).

I'd still very much like to be able to read the station number from the station directly (as discussed before in the "combinator magick" thread). And what about the "pulse" signal when the train leaves (maybe with the number of the next destination as a value)? Is that going to be possible?
Currently reading the cargo is still done by SmartTrains every few ticks, but yeah it's planned for 0.13/14

I might simply add a second combinator to the trainstop, one for the virtual signals, the other for the cargo.

Station number and pulsing is simple (i think). Station number would be constantly output. "Train leaves" signal would be set to the destination number in the tick where the other signals get cleared and unset 1 tick later?

User avatar
siggboy
Filter Inserter
Filter Inserter
Posts: 988
Joined: Tue Mar 29, 2016 11:47 am
Contact:

Re: [MOD 0.12.30+] SmartTrains 0.3.95

Post by siggboy »

Choumiko wrote:I might simply add a second combinator to the trainstop, one for the virtual signals, the other for the cargo.
I've thought about that but I don't think you should do it. First of all, it's ugly, and second of all it makes wiring up the station harder because you always have to be careful about connecting to the correct combinator (color coding the two combinators would be mandatory anyway).

Adding a second combinator just for the cargo info seems quite heavyhanded to be honest; especially since we can expect to get this information very soon from the train station proper, when the devs add that to the Vanilla game.
Station number and pulsing is simple (i think). Station number would be constantly output. "Train leaves" signal would be set to the destination number in the tick where the other signals get cleared and unset 1 tick later?
The other signals should still be available during the tick when the "train-leaves" pulse is appearing. This is important if you want to pulse something out when the train leaves. If the signals are already cleared in that tick that would not be possible anymore.

Basically, "train-at-station" and "train-leaves" should both become zero in the same tick (and "train-leaves" becomes positive for exactly 1 tick before that; possibly carrying the station number as information where the train is headed, that would be perfect).

Just to give an example how this could be used: your train has loaded some cargo, and leaves for its destination (which might be dynamically chosen, or hard configured in the UI). The pulse will give the destination number, and the cargo information would still be in the combinator at that point. So it would be very easy to send a signal over the wire with the destination number and the cargo contents. The destination station can equally easily filter that signal from the wire and it would then know what cargo it is about to receive. Having the station number of the current station in the combinator as well would make that even easier (you'd have everything output by SmartTrains and would not have to manually set any values).

Currently I'm already doing that in my setup, so the "requester" stations will stop requesting stuff that they're about to receive soon (it's actually done when the train leaves the depot, so the above would not work, but the example is still valid, I think).

Thinking about it, it could even be possible to also output a signal when a train is inbound to a station. So, for example, if the train leaves station A on it's way to station B, a "leave" signal would be generated at "A" with the destination, but also an "inbound" signal would be generated at "B" with the source. That's probably not possible if the train leaves on its own (timeout), but should at least be possible when SmartTrains itself triggers the departure.

Of course, this amounts to a kind of "wireless" communication between the stations, that could be considered OP or against the lore/spirit of the game. On the other hand, it could make some things possible without requiring to run wire between all stations, I don't know.

Most of this can be somehow simulated with circuits, but having it in the mod makes the implementations easier.
Is your railroad worrying you? Doctor T-Junction recommends: Smart, dynamic train deliveries with combinator Magick

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

Re: [MOD 0.12.30+] SmartTrains 0.3.95

Post by Choumiko »

Updated to 0.3.98 for Factorio 0.13
  • All rules (except jumpTo rules) are now set via the vanilla Schedule
  • JumpToSignal: Checks the value of the signal set in the lamp when a train with gito Signal # leaves the station. The signal condition of the lamp is ignored. If the train leaves due to passed time, the value is ignored too (same behaviour as 0.12 versions)
  • Trains only update their schedule when arriving/leaving a station
  • added 2 new signals:
    • Station # : The # of the station in the schedule where the train is currently waiting
    • Destination: The # of the station in the schedule where the train is going (only set for 1 tick)
siggboy wrote:Adding a second combinator just for the cargo info seems quite heavyhanded to be honest; especially since we can expect to get this information very soon from the train station proper, when the devs add that to the Vanilla game.
I've been thinking about removing the lamp. As it is right now i could simply say: The first conditon rule in the schedule is the signal SmartTrains will check when getting the value for jumpTo, that would make space for a second combinator. Not sure yet.
siggboy wrote:The other signals should still be available during the tick when the "train-leaves" pulse is appearing. This is important if you want to pulse something out when the train leaves. If the signals are already cleared in that tick that would not be possible anymore.

Basically, "train-at-station" and "train-leaves" should both become zero in the same tick (and "train-leaves" becomes positive for exactly 1 tick before that; possibly carrying the station number as information where the train is headed, that would be perfect).
Alright, then the current implementation isn't ideal. So the next should better be: "leaving tick" : set "train destination" signal and update cargo (so that it's exact), "leaving tick +1": unset all signals?
siggboy wrote: Thinking about it, it could even be possible to also output a signal when a train is inbound to a station. So, for example, if the train leaves station A on it's way to station B, a "leave" signal would be generated at "A" with the destination, but also an "inbound" signal would be generated at "B" with the source. That's probably not possible if the train leaves on its own (timeout), but should at least be possible when SmartTrains itself triggers the departure.

Of course, this amounts to a kind of "wireless" communication between the stations, that could be considered OP or against the lore/spirit of the game. On the other hand, it could make some things possible without requiring to run wire between all stations, I don't know.

Most of this can be somehow simulated with circuits, but having it in the mod makes the implementations easier.
Yeah.. this isn't going to happen, besides the OPness, if there is more than one station named B i have no way of knowing where the train will go.

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: [MOD 0.12.30+] SmartTrains 0.3.95

Post by Nexela »

Time to go build some train routes!!!!! Thanks for the update
Choumiko wrote: Prerelease probably in the next 3-5 hours, depending on how long Germany needs to beat Italy
I have been playing too much Hearts of Iron IV.... because that is the first thing that came to my mind when I read that.

Post Reply

Return to “Mods”