[MOD 0.15] SmartTrains 2.0.5

Topics and discussion about specific mods
JMiles
Burner Inserter
Burner Inserter
Posts: 5
Joined: Fri Apr 01, 2016 2:39 am
Contact:

Re: [MOD 0.12.27+] SmartTrains 0.3.80

Post by JMiles »

xiffix wrote:I've named the Station "Refuel L-CC"
I don't know what i'm doing wrong.

Here is the error:
Error in SmartTrains.
__SmartTrains__/gui.lua:608: attempt to index field '?' (a nil value)
I have the same problem. ;)

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

Re: [MOD 0.12.27+] SmartTrains 0.3.80

Post by Choumiko »

xiffix wrote:Error in SmartTrains.
__SmartTrains__/gui.lua:608: attempt to index field '?' (a nil value)
Fixed in SmartTrains 0.3.81

Alexs
Fast Inserter
Fast Inserter
Posts: 102
Joined: Sun Sep 07, 2014 9:46 am

Re: [MOD 0.12.27+] SmartTrains 0.3.81

Post by Alexs »

I wanted you already write, but it was just fixed time. Thank you

JMiles
Burner Inserter
Burner Inserter
Posts: 5
Joined: Fri Apr 01, 2016 2:39 am
Contact:

Re: [MOD 0.12.27+] SmartTrains 0.3.80

Post by JMiles »

Choumiko wrote:
xiffix wrote:Error in SmartTrains.
__SmartTrains__/gui.lua:608: attempt to index field '?' (a nil value)
Fixed in SmartTrains 0.3.81
Thanks, the only problem that I continue to have that I don't understand how of it works, there is very little documentation. What does a checkbox like "active", "marked" , "refuel","depart" do?

1. If "refuel" is checked, does that mean that the train will automatically refuel at the refuel station that is assigned? If so....why do we have such an option to be begin with, since every train needs to be refueled eventually.

2. What does "depart" do? I check it but nothing happens. When a trains stop at a station, I thought that checking "depart" might manually force a train to depart, after which the checkbox should go empty, but that's not the case.

3. "active"... what does that do? I'm assuming that it allows me to select the details of a train line in the top window, but why does it show 0 for "#trains" in the first train line and 1 in the other with the "active" checkbox of the 2nd train line selected, but switches to 1 for "#trains in the first train line and 0 in the second, once I check "active" of the first train line? There is 1 train on each train line, so I expected to see 1 for "#trains" in both train lines or do you ONLY show the #trains for the line that has "Active" checkbox checked?

4. "marked", what is that used for"? Only to mark a train line for deletion?

5. How do I use "signal value" in "rules"? I can check it, but then the checked box quickly returns to an empty box.

6. How do I find a station number that I can set in rules?

7. How do I set the signal for having both "FULL (AND)" with "signal" checked?

Sorry if this was explained before, but it wasn't in your first post and nobody likes to dig through the other 230 posts in this thread. :)

Xeteth
Fast Inserter
Fast Inserter
Posts: 158
Joined: Tue Feb 17, 2015 6:06 am
Contact:

Re: [MOD 0.12.27+] SmartTrains 0.3.81

Post by Xeteth »

Hey Choumiko,

I've started on my next combinator build and I've decided to make a rather large system that dynamically controls my outpost trains. Trains will be sent to the various outposts depending on the amount being mined at a given time, amount of ore in chests at the station etc. This would mean that once an outpost gets low on outputting ores a train is sent only occasionally and finally once it runs dry trains are never sent; basically supplying trains depending on demand.

I am finding this rather difficult to do however due to the way stations are identified by signal value. Currently the signal value is taken from the order that the station appears in the schedule list and unfortunately this becomes problematic when (for example) a station is removed from the schedule (ie. outpost is removed) as it bumps each station up a value and thus throws the system out of order.

Would it be possible to instead be able to set the signal value for a smart station and have that value remain regardless of the order in the schedule? This would mean that if the player dropped a station and set it as "Iron 1" (signal value = 3) then that station would always be signal value 3 regardless of what was happening in the schedule.

This would also benefit stations that are part of multiple lines, as a particular station will always have the same signal value.

Furthermore if it was possible to output that value from the smart station (or the cargo box thing) it would make identifying outposts through the circuit network much easier.

Hope this all makes sense, just an idea that I thought I'd throw your way and see if it were possible!

Cheers!

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

Re: [MOD 0.12.27+] SmartTrains 0.3.80

Post by Choumiko »

JMiles wrote:Thanks, the only problem that I continue to have that I don't understand how of it works, there is very little documentation. What does a checkbox like "active", "marked" , "refuel","depart" do?

Sorry if this was explained before, but it wasn't in your first post and nobody likes to dig through the other 230 posts in this thread. :)
Yeah, documentation is a "bit" lacking.. :roll:
JMiles wrote: 1. If "refuel" is checked, does that mean that the train will automatically refuel at the refuel station that is assigned? If so....why do we have such an option to be begin with, since every train needs to be refueled eventually.

2. What does "depart" do? I check it but nothing happens. When a trains stop at a station, I thought that checking "depart" might manually force a train to depart, after which the checkbox should go empty, but that's not the case.

3. "active"... what does that do? I'm assuming that it allows me to select the details of a train line in the top window, but why does it show 0 for "#trains" in the first train line and 1 in the other with the "active" checkbox of the 2nd train line selected, but switches to 1 for "#trains in the first train line and 0 in the second, once I check "active" of the first train line? There is 1 train on each train line, so I expected to see 1 for "#trains" in both train lines or do you ONLY show the #trains for the line that has "Active" checkbox checked?

4. "marked", what is that used for"? Only to mark a train line for deletion?

5. How do I use "signal value" in "rules"? I can check it, but then the checked box quickly returns to an empty box.

6. How do I find a station number that I can set in rules?

7. How do I set the signal for having both "FULL (AND)" with "signal" checked?
1. You are right in every point. Trains with refuel set only add the refueling Station to their schedule when they have to. The reason for this option is more or less for self-set rules/"realism", have dedicated stations for refueling and don't bother supplying each and every station in your base with fuel. It might actually be more usefull for long long trainlines, where a train could run out of fuel before coming back to the base (since i assume most players don't refuel at outposts), though i have yet to see an outpost that is that far away :D

2. That's actually explained in the first post
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)
Basically a "leave when no change in cargo for 2 seconds" rule. Added way before the full/empty/signal stuff

3. Active is to assign the currently opened train to that specific line (or to unassign it). That's also why you see #trains changing.

4. You can mark multiple lines to delete them, or mark one to rename it. The positioning is probably not that good, maybe it should be right of the "Rules" buttons or all the way to the left?

5. "signal value" is only available when you check "signal" first. Having both checked makes trains go the the station in their schedule that is on the position indicated by the signal you set at the light of the SmartTrain stop. E.g.
Image
Imagine the red wire coming from some combinator contraption which decides where your train should go. If it outputs green signal = 1 the lamp would turn on and your train would go to the first station in the schedule, to the third for 3 and so on. If the signal is higher than the stations in the schedule it goes to the next one after the current one.

6. See 5. Goto station # is similar to "signal value" only that it is a fixed number.

Both options have in common that the train goes to the next station if the waiting time is passed (unless wait forever is set) or the number is invalid

7. Simply check both :D The (AND) is supposed to be an indicator that both rules have to be true. Also a reminder for me to replace it with a toggle button for AND/OR

If you have any more questions just post them, maybe i then can simply mash my answers together for an actual documentation ;)
Xeteth wrote:I've started on my next combinator build and I've decided to make a rather large system that dynamically controls my outpost trains. Trains will be sent to the various outposts depending on the amount being mined at a given time, amount of ore in chests at the station etc. This would mean that once an outpost gets low on outputting ores a train is sent only occasionally and finally once it runs dry trains are never sent; basically supplying trains depending on demand.
You're nuts :D
Xeteth wrote: I am finding this rather difficult to do however due to the way stations are identified by signal value. Currently the signal value is taken from the order that the station appears in the schedule list and unfortunately this becomes problematic when (for example) a station is removed from the schedule (ie. outpost is removed) as it bumps each station up a value and thus throws the system out of order.

Would it be possible to instead be able to set the signal value for a smart station and have that value remain regardless of the order in the schedule? This would mean that if the player dropped a station and set it as "Iron 1" (signal value = 3) then that station would always be signal value 3 regardless of what was happening in the schedule.

Furthermore if it was possible to output that value from the smart station (or the cargo box thing) it would make identifying outposts through the circuit network much easier.
You basically want a fixed mapping of Station name to a number? I'm a bit worried about backwards compatibility, unless i add yet another checkbox (YAC :D ) to use the lookup table (better naming suggestions welcome).

How should this behave for cases where you have the same station in the schedule multiple times? Probably go to the first one it finds after the current one?

Outputting the station# isn't a problem, a few lines of code and creating an icon. Though the "cargo box thing" starts to have so many virtual signals that it's nearly worth considering adding an extra one just for the special signals.

I think once my rewrite of FatController is done i'll get to it, really want to see your setup :)

Xeteth
Fast Inserter
Fast Inserter
Posts: 158
Joined: Tue Feb 17, 2015 6:06 am
Contact:

Re: [MOD 0.12.27+] SmartTrains 0.3.80

Post by Xeteth »

Choumiko wrote:You're nuts :D

Thankyou! :D
Choumiko wrote: You basically want a fixed mapping of Station name to a number? I'm a bit worried about backwards compatibility, unless i add yet another checkbox (YAC :D ) to use the lookup table (better naming suggestions welcome).

How should this behave for cases where you have the same station in the schedule multiple times? Probably go to the first one it finds after the current one?

Outputting the station# isn't a problem, a few lines of code and creating an icon. Though the "cargo box thing" starts to have so many virtual signals that it's nearly worth considering adding an extra one just for the special signals.

I think once my rewrite of FatController is done i'll get to it, really want to see your setup :)
Yep, custom mapping for the station signal values so that they can remain constant when stations are added/removed would be awesome :D

Just an idea - could it be set at the station itself via entering it in to a constant combinator type thing? That would remove the need for changing the GUI (I hear the GUI can be hard to change/mod sometimes) and could double up as the way that the player can output that station signal number to the circuit network. I have no idea if this is possible or something that would work though.

I don't see it being too much of a problem when you have the same station multiple times because you'd just send the train to that station each time with the custom mapped signal value unless I'm missing something?

Being able to output that station value would be awesome! Would make identifying stations much, much easier for later use within the train-sending combinator build :D

No worries take your time, looking forward to seeing the FatController re-write as well. Honestly don't know how I ever played Factorio without ST, FC and FARL haha.

JMiles
Burner Inserter
Burner Inserter
Posts: 5
Joined: Fri Apr 01, 2016 2:39 am
Contact:

Re: [MOD 0.12.27+] SmartTrains 0.3.80

Post by JMiles »

Thanks Choumiko, you've been a great help! :)

Btw, no wonder why I didn't understand some of the issues that I had, because believe it or not, I didn't see that your mod added a smart train stop, I was still using Factorio's own train stop! :oops:

One last question; where did you find the documentation (about the game) that is needed to write these mods? I was a professional programmer before I became a systems administrator, so I have the programming skills (also in LUA) and I'm also skilled in 2d and 3D graphic design, and I was thinking about writing a mod for Factorio, but without any proper documentation about the internals of the game, there is not a lot I can develop. :)
So where did you get that info?

lamhirh
Manual Inserter
Manual Inserter
Posts: 4
Joined: Wed Mar 23, 2016 7:10 pm
Contact:

Re: [MOD 0.12.27+] SmartTrains 0.3.81

Post by lamhirh »

Can you make trun run on signal only ( or wait just for signal)? I want the train to run only whan cetain resource in storage drop under certain level.

For now it either ignores signal, waits for timer and runs, or waits till full AND signal. well actually it mostly ignores the settings anyway. Only one that works is wait forever. MAkes the train not move at all:P

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

Re: [MOD 0.12.27+] SmartTrains 0.3.81

Post by Choumiko »

lamhirh wrote:Can you make trun run on signal only ( or wait just for signal)? I want the train to run only whan cetain resource in storage drop under certain level.

For now it either ignores signal, waits for timer and runs, or waits till full AND signal. well actually it mostly ignores the settings anyway. Only one that works is wait forever. MAkes the train not move at all:P
Image
Setting the rules like above should do what you want (that is, if you connect the lamp of the smart trainstop to the circuit network and set the condition the way you need it "resource x" < Z i guess) If it doesn't work i'd like a screenshot of the rules window and the combinator setup at your smart trainstop.

lamhirh
Manual Inserter
Manual Inserter
Posts: 4
Joined: Wed Mar 23, 2016 7:10 pm
Contact:

Re: [MOD 0.12.27+] SmartTrains 0.3.81

Post by lamhirh »

Hmm i might overthink it. i made a combinator to send blue if metal < 400k and light to blue=1.

Was going away after 3o seconds.

Now made new train. Set to leave on full. Saved. Runs on default timer again :(

http://images.akamai.steamusercontent.c ... 40E750270/

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

Re: [MOD 0.12.27+] SmartTrains 0.3.81

Post by Choumiko »

I don't understand what you're trying to do. The trainline and rules as setup in the screenshot will make the train leave the R1 -stone station when the trains cargo wagons are full OR when the time has passed.
Where are you getting the metal signal from? If you check the "signal" checkbox in the rule window, the train will leave when it is full AND the signal is valid (metal < 4000k in your case).

JMiles
Burner Inserter
Burner Inserter
Posts: 5
Joined: Fri Apr 01, 2016 2:39 am
Contact:

Re: [MOD 0.12.27+] SmartTrains 0.3.80

Post by JMiles »

JMiles wrote:One last question; where did you find the documentation (about the game) that is needed to write these mods? I was a professional programmer before I became a systems administrator, so I have the programming skills (also in LUA) and I'm also skilled in 2d and 3D graphic design, and I was thinking about writing a mod for Factorio, but without any proper documentation about the internals of the game, there is not a lot I can develop. :) So where did you get that info?
What? No answer? Too afraid to get competition? :)

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

Re: [MOD 0.12.27+] SmartTrains 0.3.80

Post by Choumiko »

JMiles wrote:What? No answer? Too afraid to get competition? :)
:lol: No, of course not.
Check out these links:
http://lua-api.factorio.com/
https://wiki.factorio.com/index.php?title=Modding
https://wiki.factorio.com/index.php?title=Lua/Game (at the bottom are links to different Lua objects)
The wiki is slightly outdated at times, but i still find it rather helpful, especially since my browser history shows me all i need when typing Lua/ :D

JMiles
Burner Inserter
Burner Inserter
Posts: 5
Joined: Fri Apr 01, 2016 2:39 am
Contact:

Re: [MOD 0.12.27+] SmartTrains 0.3.81

Post by JMiles »

Thanks Choumiko, you've been a great help. ;)

User avatar
MalcolmCooks
Filter Inserter
Filter Inserter
Posts: 253
Joined: Mon Apr 06, 2015 8:32 pm
Contact:

Re: [MOD 0.12.27+] SmartTrains 0.3.81

Post by MalcolmCooks »

Is there a way to have a train, after being dispatched to a certain station by a signal value, to then return straight back to the first station again instead of visiting all the remaining stations on the schedule?

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

Re: [MOD 0.12.27+] SmartTrains 0.3.81

Post by Choumiko »

MalcolmCooks wrote:Is there a way to have a train, after being dispatched to a certain station by a signal value, to then return straight back to the first station again instead of visiting all the remaining stations on the schedule?
Like this

Code: Select all

Station A <- sends train to station C via signal value
Station B
Station C <-- sends train to A, when it came from there, to D otherwise?
Station D
So basically you'd want "came from A" as a signal condition at station C. SmartTrains doesn't remember where it came from, so without some combinator magic it's not possible. What's the use case for that?

User avatar
MalcolmCooks
Filter Inserter
Filter Inserter
Posts: 253
Joined: Mon Apr 06, 2015 8:32 pm
Contact:

Re: [MOD 0.12.27+] SmartTrains 0.3.81

Post by MalcolmCooks »

Sorry, I worked it out with some experimenting.

I have a coal supply train, with one loading station, and multiple unloading stations. It waits at the loading station, until one of the unloading station sends a signal that it needs coal.
Station one is loading, conditions are leave when full AND signal, go to signal #
The other stations are unloading, conditions are leave when empty

A problem with this is that if more than one station sends a request, the go to signal will send the train to the wrong station. So I have a failsafe that makes an invalid go to signal if that happens, default behaviour is then to visit each station in schedule order.

In both cases after being unloaded the train goes to each station after that in the schedule before going back to the loading station.

I need the unloading stations to be leave when signal, go to 1, and have the signal condition set appropriately so it will be true if:
1) the stations request has been fulfilled (same as train is empty) OR
2) the station did not send a request signal

Then, if one station sends a request it works like this: Train goes to that station, is unloaded, returns to the loading station.
If more than one station sends a request: Train visits each station. If the station doesn't need coal, it goes to the next one. If the station does need coal, it is unloaded and returns straightaway to the the loading station.

User avatar
MalcolmCooks
Filter Inserter
Filter Inserter
Posts: 253
Joined: Mon Apr 06, 2015 8:32 pm
Contact:

Re: [MOD 0.12.27+] SmartTrains 0.3.81

Post by MalcolmCooks »

MalcolmCooks wrote:Sorry, I worked it out with some experimenting.
I found a better way to do it. Schedule goes

1. unloading A [leave when empty]
2. loading [leave when full AND signal, wait forever, go to station # signal value]
3. unloading B [leave when empty]
4. loading [leave when full AND signal, wait forever, go to station # signal value]
ect.

Arithmetic combinators will negate the signals in order of priority, so if more than one signal is coming through, only the highest priority signal will make it through.

!Ice-Man!
Manual Inserter
Manual Inserter
Posts: 4
Joined: Wed Apr 06, 2016 10:10 am
Contact:

Re: [MOD 0.12.12+] SmartTrains 0.3.73

Post by !Ice-Man! »

NearlyDutch wrote:So I was making my train network a little bit smarter with the introduction of smart train stops, but I get the following error, whenever a train uses a smart train stop:

Code: Select all

Error in SmartTrains:
__SmartTrains__/Train.lua:240:conversion of data to type "j" failed
This only happens with smart train stops, normal ones have no problem. I wanted to make my trains go to ore outpost after ore outpost until they are full and then goto the unloading station. That's why I was reworking my train network with smart train stops, but whenever I place one, a train arrives at one or departs from one, this error is printed.

P.S.: Already tried hard resetting with the remote interface.
Same error here, but in line 250...

Tried to load yout demosave, even there. Latest version factorio, latest version mod.

Post Reply

Return to “Mods”