Offload based on train contents and a set limit?

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Post Reply
dewitpj
Inserter
Inserter
Posts: 24
Joined: Sat Jul 09, 2016 7:57 am
Contact:

Offload based on train contents and a set limit?

Post by dewitpj »

Ok - I must be a muppet, but for the life of me I can't get the math decider working as I understand it:

What I would like to do is get the signal of a parked train, say wires and only offload if there is less than a certain amount in my network. I assume it to be something like the following:

Signal from Train Stop on green wire
Signal from decider on red wire (Decider has a input of L - limit and then the output of a roboport for logistics)

If signal from red (wires) AND green (wires) then output "1"

Given that - 0 AND 0 = 0,...... 1 AND 1 = 1 this should work right ?

This should be expanded to coal, plates etc, based on what the train has (I have no mixed trains)

Here is a screen shot of the current, non-working layout

(Edit - Had the wires the wrong way around :( )
Attachments
Screen Shot 2017-11-15 at 7.54.23 PM.png
Screen Shot 2017-11-15 at 7.54.23 PM.png (551.01 KiB) Viewed 1778 times

User avatar
Lav
Filter Inserter
Filter Inserter
Posts: 384
Joined: Mon Mar 27, 2017 10:12 am
Contact:

Re: Offload based on train contents and a set limit?

Post by Lav »

So, to summarize:

*) You store a number of different resources at the station.
*) You have trains coming each carrying one of those resources.
*) You want the train to unload only if it carries a resource your station accepts, and your station's storage of that particular resource is less than some specified amount?

Assuming that's correct, I'd suggest the following schematic:

Image

A few decider combinators, a single constant (to store the requested amounts) and a single arithmetic.

Set your unloading inserters to activate on A=1 of the rightmost combinator, and it should work... in theory.
More detailed explanation
Note however that if you're unloading different resources on your station, it's possible that some resource demand is satisfied, but a train with that resource will still arrive. You'll probably need to set your train's departure condition to "inactivity > some_period" to ensure that your trains will eventually leave even if their product isn't required by the station, or add a separate circuit to generate a departure signal for the train. Though either way you will have a lot of "empty" trips by fully loaded trains to your station.

leitk
Fast Inserter
Fast Inserter
Posts: 115
Joined: Wed Jun 21, 2017 7:20 pm
Contact:

Re: Offload based on train contents and a set limit?

Post by leitk »

A slight simplification (since I had the same problem dewitpj brought up, and came up with the same solution Lav mentioned.

If you have your constants as negative numbers, you don't need the * -1 combinator. and the one reading the chests becomes (IF each < 0 SET each 1).

Then take the last combinator and have it be EACH -1 output EACH, and feed that to a stack filter with set filter. I had mixed trains, so I had to send to a filter inserter, if you're going to a non filter insterter you could use eith the EACH -1 or the if ANY = 2, for EACH - 1 you should be able to set the inseters to ANY = 1, I have set up the filter version and it works well. I have not tried the non filtered version.

Station read train ----- if EACH > 0 set EACH = 1 (this says the train has something)
Chest plus negative constants ----- if EACH < 0 set EACH = 1 (this says we want something)
Feed both of those into ------ EACH - 1 output EACH (this turns the signal off unless both are true)
Feed that into a stack filter insterter. It will take slightly more (up to stack size - 1), if that's not acceptable the problem gets harder.

dewitpj
Inserter
Inserter
Posts: 24
Joined: Sat Jul 09, 2016 7:57 am
Contact:

Re: Offload based on train contents and a set limit?

Post by dewitpj »

(Sorry for the delay in my reply to you guys...been busy...gaming ? :D)

Some good ideas, but I have always had a problem implementing this (same for the segment displays, I just struggle)

I ended up doing the following:

1) If a certain item is needed a signal of 1 is sent using say "A"
2) if the train contains the same item, another signal of "A" is sent
3) The above signals are on the same network so they are added together
4) If "A"=2 then set "Inserters signal to 1"
5) If "Inserters signal"==1 unload

:)

Post Reply

Return to “Gameplay Help”