Factory Town

Factory Town

View Stats:
Automatic Reset Logic Counter?
Hey, I suck with the logic blocks because I don't fully understand them all, and I can't quite grasp yet the entirety of signals being sent and everything being binary 1 or 0.

I want to make a counter that automatically resets back to zero once it reaches a set number such as five.

I was almost able to figure out how to get kind of close to having something working, but still not at all, and it's one of those things where I just get more frustrated as I attempt to make it yet still fail due to not fully understanding what I'm doing.

So can anybody help me out here with this? I feel like if I know how to do that then I will understand the logic blocks far better, I'm just not at that stage yet, I need guidance, a tutorial guide that I can read that also has diagrams. A lot of the videos either aren't in depth enough or they're not focused enough, whatever it is they just don't really do it for me, I learn better through reading and internalizing information that way.
< >
Showing 1-11 of 11 comments
Lil Puppy May 16, 2019 @ 3:01pm 
If (X =5) { Set X = 0 }

So like
inventory sensor -> counter block -> math block (==5) -> set block (set to 0) -> counter block

something like that.
You could go super complicated and make a binary counter that triggers the same thing but since these blocks exist, it's easier this way.
Originally posted by Lil Puppy:
If (X =5) { Set X = 0 }

So like
inventory sensor -> counter block -> math block (==5) -> set block (set to 0) -> counter block

something like that.
You could go super complicated and make a binary counter that triggers the same thing but since these blocks exist, it's easier this way.

That doesn't work, those blocks connected in that order causes the counter block to reset to zero every time a cart passes the inventory sensor.

How do I make it so that the logic set block only sends the signal to reset the counter to zero when it reaches the set value?

It's missing an operator or something.
Lil Puppy May 17, 2019 @ 10:20am 
Well that's inconvenient, it should work, it works in code...
So set it to >5 instead of ==5.
Originally posted by Lil Puppy:
Well that's inconvenient, it should work, it works in code...

Well it's not code man, it is its' own system, and apparently it's binary as in each signal sent carries either a one or a zero.

Some people have it figured out and I've figured out at least one very basic thing thanks to a persons demonstration video, but I still don't entirely understand it because they don't explain, so i don't know why I have to use the math block function I'm using, I just know that it works.

I've been trying to figure it out to no avail I just get frustrated unable to figure it out and give up until I feel up to trying again.
Lil Puppy May 17, 2019 @ 9:58pm 
Well, the thing about code is that this is a game, not an electronic device, therefore if it works in code, it will work in game code. I've found that the == doesn't always work though in many things where it should work perfectly.

As a programmer myself I understand these game logic systems better than most.

Also, if you're using this on a train track, it's no wonder it trips every time one goes by.
Each train cart can hold 12 (I think) items so if you're counting to 5, it's actually tripping because the inventory of the cart is over 5.

So the system, either version, is working properly, you're just using it wrong since the vehicle you're checking inventory on is using a larger number. I figured you were using it on a silo or barn, not a vehicle.

The math block, counter blocks, set block, inventory block, and several other blocks don't use binary. And in code it's all event driven so it only trips once per activation. The blocks that use binary are the explicit logic block parts of the math block ( or, nor, not, xor, etc. ) and those only care if the number is either a 0(zero) or a + or - non-zero (logic 1).

Without all the information on how you want it to act and what it is acting on, it's a little more difficult to create a logic computer to do what you want it to do.

Anyway, either of the samples I've listed work just fine with a cart according to your requirements that you've posted in this thread. If you're trying to do something other than count how much is in a cart when it passes through a sensor, you need to be a little more explicit in your description of the functionality you require.

If you want the circuit to reset to zero every time a cart goes by that is full, you need to do:

Inventory sensor (on track) -> counter -> math block ( ==12 ) or ( >11 ) -> set block ( 0 ) -> counter block.

That will make the cart tell the inventory sensor how many items it is carrying, that number is then recorded in the counter block, the counter block then sends the number to the math block that applies a conditional check on that number "If cart.inventory equals 12 or is greater than 11 { do something }". If the condition is met the math block then sends a TRUE signal to the set block which then sets the counter block back to 0 ( zero ).

Anyway, I'll check the circuit in-game, but I don't fully know what you're trying to accomplish with this so it's still just a preliminary design.
Decius Brutus May 18, 2019 @ 9:49pm 
My guess is that the bug in the implementation described is the set block being active all the time, rather than only when the math block is true.
Originally posted by Lil Puppy:
...if you're using this on a train track, it's no wonder it trips every time one goes by.
Each train cart can hold 12 (I think) items so if you're counting to 5, it's actually tripping because the inventory of the cart is over 5.

But it's only analyzing empty carts, so the inventory count should be zero.

I've also tried using the agent trigger block instead of the inventory sensor but I still can't get that to work, as the agent trigger only sends a signal once the cart goes by it and completely ignores the inventory so that tells me that the issue is not with the inventory, even when using the inventory sensor.

I'm not trying to count inventory, I just want to count the rail cars that go past the sensor block so I can time how long it takes for all the carts to make a complete circuit.
Lil Puppy May 19, 2019 @ 11:45pm 
Ok, this was a lot more complicated than it should have been.
https://steamcommunity.com/sharedfiles/filedetails/?id=1746897279

SO if counting to 5:

Agent -> Counter -> Math (<=4) -> Boolean (NOT) ->
Number Block (Optional) -> Timer Block & Set Block ...
---Timer Block -> Signal Gate...
---Set Block -> Signal Gate...
Signal Gate -> Logic Pusher Block -> Number Block (set to 0) -> Set Block -> original Counter Block

The Boolean(NOT) gate is usually called an Inverter in most games with circuits, it turns a 1 into a 0 and a 0 into a 1, it is necessary in this circuit. The Number Block (Optional) can be taken out if you want, I left it in there for visual confirmation.

Additionally, if you want it to control a barrier gate that blocks the carts, connect the Math block to the barrier gate.

This circuit will count from 0 - 4 (5 total transits past the agent sensor), and then reset the counter to zero, if the math block is connected to a barrier gate, the circuit will also stop the carts from moving.
Last edited by Lil Puppy; May 19, 2019 @ 11:49pm
Wow, I am just blown away, this is amazing. I knew it wasn't as simple as I hoped it would be I just don't know enough yet about all the logic blocks to know how to do what you did. Thanks a bunch, this is fantastic.
Superkefir Aug 29, 2019 @ 5:12am 
Hi guys!
Lil Puppty, thanks for this useful help, i use you idea with my conveyors.
But also with your scheme i use standart inventory sensor->number block->math block to start grabber when at last point of conveyor there is empty market for example. But if conveyor is long than 10 points, than i have another problem, how to stop grabber after this 10 pcs for example cause the block that i use is always try to open it. I tried to add timer block but it doesn't help. I use the silo as a buffer but sometimes it's overflowing. The idea is to activate a grabber then your scheme count 10 times and close it and then until the items are on the conveyour the block that open this grabber for filling empty market shouldn't open. I think to add bool for this. After last 0 add logic NOT than timer and then BOOL function AND that will use this 0->1 and timer(25) AND empty market to activate grabber. Will it work or maybe there is some simple solution for this?
Last edited by Superkefir; Aug 29, 2019 @ 5:12am
Lil Puppy Aug 29, 2019 @ 7:50pm 
There are several ways to do this.
If market_inventory <1 { barn_grabber(open) }

inventory sensor on market with item filter to math block <1 (because == doesn't always work because of the way the event triggers work)
math block to barn grabber (this will open the flow when the market is empty of that item)

now to close the grabber
if agent_counter >9 { barn_grabber(close); set counter(0); }
agent on second conveyor slot (after grabber, this will give 10 items) connected to a counter block
counter block to math block >9
math block to inverter(boolean not so we can turn the 1 into a zero)
inverter connected to a set block connected to the counter block (this should use the zero from the inverter to set the counter block to zero again, if it doesn't, use part of the reset circuit above to do it).
inverter connected to the grabber to close the barn.

So this should sense when the market is empty of the item you want from the barn and then send 10 items to the market regardless of conveyor length and close the barn doors when those 10 items have been counted.

NVM... this wont work but I don't have time right now to fix it...
Last edited by Lil Puppy; Sep 1, 2019 @ 9:37am
< >
Showing 1-11 of 11 comments
Per page: 1530 50

Date Posted: May 16, 2019 @ 4:40am
Posts: 11