Is it possible to read the amount of fluid in a fluid wagon and output the result to a signal?
Is it possible to read the amount of fluid in a fluid wagon and output the result to a signal?
I want to check to see how much of a fluid is in the wagon, and disable the pump if its below a certain point. Is it possible to check how much fluid is in a fluid wagon in order to disable a pump?
Re: Is it possible to read the amount of fluid in a fluid wagon and output the result to a signal?
For a train at a train stop, you can read its contents through a circuit connection to the train stop. That is the sum of all wagons rather than an individual wagon, but it is the closest you can get.
Re: Is it possible to read the amount of fluid in a fluid wagon and output the result to a signal?
If you want to know the contents of a specific wagon, and not the whole train (if more than one wagon have the same fluid), you have to use the Inventory Sensor mod. It uses resources checking for something to read all the time but does what it says.
My mods: Multiple Unit Train Control, Smart Artillery Wagons
Maintainer of Vehicle Wagon 2, Cargo Ships, Honk
Maintainer of Vehicle Wagon 2, Cargo Ships, Honk
-
- Fast Inserter
- Posts: 208
- Joined: Tue Apr 24, 2018 5:42 am
- Contact:
Re: Is it possible to read the amount of fluid in a fluid wagon and output the result to a signal?
This is correct but I want to point out a small exception and give you a warning.
The exception would be the situation where your fluid wagons have different fluids in them. In that case it's trivial but I suspect this isn't the situation you're interested in.
So the warning -
Fluid counts have decimal points. Circuit networks only allow integers and they truncate. Depending on what exactly it is that you're trying to do, this can cause some big problems. Just by way of example, suppose that your fluid wagon has 0.8723 oil in it. The circuit network will read that as 0. If you actually need precision, you'll have to deal with barrels.
Re: Is it possible to read the amount of fluid in a fluid wagon and output the result to a signal?
Also beware the the number is rounded to the nearest integer. So 0.5 fluids will read as 0.
Re: Is it possible to read the amount of fluid in a fluid wagon and output the result to a signal?
ColonelSandersLite wrote: βMon Sep 12, 2022 3:39 pmCircuit networks only allow integers and they truncate.
At most one of these statements can be correct .
-
- Fast Inserter
- Posts: 208
- Joined: Tue Apr 24, 2018 5:42 am
- Contact:
Re: Is it possible to read the amount of fluid in a fluid wagon and output the result to a signal?
I'm pretty sure that it's truncation but It's possible that I'm wrong. It has happened!SoShootMe wrote: βMon Sep 12, 2022 4:38 pmColonelSandersLite wrote: βMon Sep 12, 2022 3:39 pmCircuit networks only allow integers and they truncate.At most one of these statements can be correct .
Re: Is it possible to read the amount of fluid in a fluid wagon and output the result to a signal?
Depends on your definition of nearest.SoShootMe wrote: βMon Sep 12, 2022 4:38 pmColonelSandersLite wrote: βMon Sep 12, 2022 3:39 pmCircuit networks only allow integers and they truncate.At most one of these statements can be correct .
ColonelSanderLite is probably correct though. My points stands though that checking if fluid is 0 doesn't work and leaves tiny bits in the train.
-
- Smart Inserter
- Posts: 2622
- Joined: Tue Apr 25, 2017 2:01 pm
- Contact:
Re: Is it possible to read the amount of fluid in a fluid wagon and output the result to a signal?
For clarity sake, you probably should say "rounded down to the nearest integer", because otherwise mine (and I suspect many other's) interpretation of your line would mean that 0.5 rounds to 1, not 0.
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles | New Gear Girl & HR Graphics
-
- Fast Inserter
- Posts: 208
- Joined: Tue Apr 24, 2018 5:42 am
- Contact:
Re: Is it possible to read the amount of fluid in a fluid wagon and output the result to a signal?
That *hurts* my programmer brain because it's self contradicting... I think I know what it means but my brain thinks it's some kinda cruel buddist khone or something.FuryoftheStars wrote: βMon Sep 12, 2022 4:47 pmFor clarity sake, you probably should say "rounded down to the nearest integer"
That being said, I checked the wiki for an answer to this after my last post and it says
Same self-contradiction but the second part is new. Wonder when that happened? I'm assuming it's accurate.When reading the content of a stopped train, fluid amounts are rounded down to the nearest integer, except when the fluid amount is < 1, then it is is rounded to 1.
Re: Is it possible to read the amount of fluid in a fluid wagon and output the result to a signal?
https://wiki.factorio.com/index.php?tit ... did=182702ColonelSandersLite wrote: βMon Sep 12, 2022 4:52 pmSame self-contradiction but the second part is new. Wonder when that happened? I'm assuming it's accurate.
Given that the changed occured between October and December 2020. It would seem that it is the case since the version 1.1
-
- Smart Inserter
- Posts: 2622
- Joined: Tue Apr 25, 2017 2:01 pm
- Contact:
Re: Is it possible to read the amount of fluid in a fluid wagon and output the result to a signal?
Can you better define what you mean? I don't follow.ColonelSandersLite wrote: βMon Sep 12, 2022 4:52 pmThat *hurts* my programmer brain because it's self contradicting... I think I know what it means but my brain thinks it's some kinda cruel buddist khone or something.FuryoftheStars wrote: βMon Sep 12, 2022 4:47 pmFor clarity sake, you probably should say "rounded down to the nearest integer"
Also, my reply was more aimed at mrvn as their post merely said "rounded to the nearest integer".
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles | New Gear Girl & HR Graphics
Re: Is it possible to read the amount of fluid in a fluid wagon and output the result to a signal?
I get where you're coming from but I think it can be read as precise, not a contradiction: down tells you the rounded value must not be greater than the true value, nearest tells you the rounded value must have the least absolute difference to the true value (arguably implied by "rounded"), and integer tells you the rounding is to that rather than (say) a multiple of ten.ColonelSandersLite wrote: βMon Sep 12, 2022 4:52 pmThat *hurts* my programmer brain because it's self contradicting...FuryoftheStars wrote: βMon Sep 12, 2022 4:47 pmFor clarity sake, you probably should say "rounded down to the nearest integer"
I should have checked the Wiki myself... I had a feeling there was some exceptional behaviour but wasn't certain so cut it before posting.That being said, I checked the wiki for an answer to this after my last post and it says
When reading the content of a stopped train, fluid amounts are rounded down to the nearest integer, except when the fluid amount is < 1, then it is is rounded to 1.
I'm not sure it's quite right though, I think it should be "when 0 < fluid amount < 1", ie exactly 0 gives no signal. This means a signal will be present unless there is no fluid.
Re: Is it possible to read the amount of fluid in a fluid wagon and output the result to a signal?
If you round to the nearest integer, it's sometimes rounded up, sometimes rounded down, if you always round down (to an integer) the name is truncated. ( that was for fury, i guess that explain why it could mess with some people's brain )
But if for only 1 number you are not truncating ? then you got the factorio wiki
( agree with shootme)
(had to edit to be precise duh )
But if for only 1 number you are not truncating ? then you got the factorio wiki
( agree with shootme)
(had to edit to be precise duh )
Re: Is it possible to read the amount of fluid in a fluid wagon and output the result to a signal?
Seems like the quoted sentence is of my creation. I don't understand the confusion about rounded down. I'm very used to the word "abrunden", which is my first language version of "rounded down". The fact that I can link to a wikitionary entry of that makes it a "real word" to me, not just an invention of my German brain wanting an English equivalent :P
Anyway, better phrasing ideas that still convey truncated to nearest integer/rounded down to nearest integer and the < 1 but > 0 special case of rounding to 1 are appreciated/invited to be implemented on the wiki.
Anyway, better phrasing ideas that still convey truncated to nearest integer/rounded down to nearest integer and the < 1 but > 0 special case of rounding to 1 are appreciated/invited to be implemented on the wiki.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
-
- Smart Inserter
- Posts: 2622
- Joined: Tue Apr 25, 2017 2:01 pm
- Contact:
Re: Is it possible to read the amount of fluid in a fluid wagon and output the result to a signal?
This is exactly how I meant it and as I've always understood that phrase to mean. Without the specification of "nearest integer", you're leaving it open to interpretation that could mean to the nearest multiple of 10, or 1/10th.SoShootMe wrote: βMon Sep 12, 2022 6:00 pmI get where you're coming from but I think it can be read as precise, not a contradiction: down tells you the rounded value must not be greater than the true value, nearest tells you the rounded value must have the least absolute difference to the true value (arguably implied by "rounded"), and integer tells you the rounding is to that rather than (say) a multiple of ten.ColonelSandersLite wrote: βMon Sep 12, 2022 4:52 pmThat *hurts* my programmer brain because it's self contradicting...FuryoftheStars wrote: βMon Sep 12, 2022 4:47 pmFor clarity sake, you probably should say "rounded down to the nearest integer"
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles | New Gear Girl & HR Graphics
Re: Is it possible to read the amount of fluid in a fluid wagon and output the result to a signal?
I don't think it's confusing when you say rounded down to the nearest integer, i guess it comes from how you learn it. Roundings is the word i remember from physic class where you need to know how many signficant digits should be indicated given the precisions of your measure, it doesn't have to be an integer although it could be, you can have a number like 12.2423 and say it's rounded up or down, to the xth digit to keep the number of significant digits. maybe the number was 12.2423299632... because you got it from a division but your measure instrument is not as precise enough for the last digits to mean anything so you round off the number.
Truncated would be the math teacher word (and computer science) to describe the process of discarding the part that is after the decimal point. And if you were to call it a rounded down number the teacher would tell you that you are not in physics class
At least that was the case with french teacher, there are the equivalent of the two words as in english, "arrondi"= rounded ; "troncature" = truncation. The french part of the wiki doesn't contain translation for this particular part to illustrate though.
In english there is also the "floor" function, i'm not sure which one is the most precise for describing what happens in factorio, especially if there is 2 different method for different interval.
Edit: Though , looking at it a bit more, ColonelSanders used the word " selfcontradiction" and not "confusion", i think then it would refers to something like 14.7 being rounded to down to 14, which is then not the "nearest" integer ?
Re: Is it possible to read the amount of fluid in a fluid wagon and output the result to a signal?
Wow, that has been a feature request for ages and the devs where on the fence about that change. I hope it's true, this was so annoying when dealing with fluid wagons and circuit porgraming.ColonelSandersLite wrote: βMon Sep 12, 2022 4:52 pmSame self-contradiction but the second part is new. Wonder when that happened? I'm assuming it's accurate.When reading the content of a stopped train, fluid amounts are rounded down to the nearest integer, except when the fluid amount is < 1, then it is is rounded to 1.
Re: Is it possible to read the amount of fluid in a fluid wagon and output the result to a signal?
For a programmer "round" is the function where "abs(x - round(x))" is smallest and 0.5 rounds to 1. Like people round numbers.Bilka wrote: βMon Sep 12, 2022 6:18 pmSeems like the quoted sentence is of my creation. I don't understand the confusion about rounded down. I'm very used to the word "abrunden", which is my first language version of "rounded down". The fact that I can link to a wikitionary entry of that makes it a "real word" to me, not just an invention of my German brain wanting an English equivalent
Anyway, better phrasing ideas that still convey truncated to nearest integer/rounded down to nearest integer and the < 1 but > 0 special case of rounding to 1 are appreciated/invited to be implemented on the wiki.
"rounded down" is "floor" or simply truncated and "rounded up" is "ceil"(ing).