[0.9.0] Not sure if it is a bug (Control.lua, getliquid())

Bugs that are actually features.
Post Reply
ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

[0.9.0] Not sure if it is a bug (Control.lua, getliquid())

Post by ficolas »

I tried to get liquid from a entity in the control.lua, but it doesnt seem to work (returns nil), the entitt is a storage tank, I tried to do it in the console, and it works.
Im sure the entity is a storage tank, because I printed the name.

Edit: Not sure if this matters but it is in the onguiclick event.

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: [0.9.0] Not sure if it is a bug (Control.lua, getliquid(

Post by kovarex »

I tried it in the console as well and it works, I don't know why it couldn't work, are you sure it is not some other error?
Can you minimise the error to smallest possible code example ?

immibis
Filter Inserter
Filter Inserter
Posts: 303
Joined: Sun Mar 24, 2013 2:25 am
Contact:

Re: [0.9.0] Not sure if it is a bug (Control.lua, getliquid(

Post by immibis »

What happens if you connect pipes to all possible connection spots?

getliquid returns the contents of one "fluid container" and you can't specify which one, so it might be getting the fluid in one of the pipe connections.

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: [0.9.0] Not sure if it is a bug (Control.lua, getliquid(

Post by kovarex »

immibis wrote:What happens if you connect pipes to all possible connection spots?

getliquid returns the contents of one "fluid container" and you can't specify which one, so it might be getting the fluid in one of the pipe connections.
The pipe has just one fluidbox, so this method will work fine for it. The count of connections of the fluidbox doesn't really matter.

ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: [0.9.0] Not sure if it is a bug (Control.lua, getliquid(

Post by ficolas »

Ok sorry for tanking so long answering this.
Is not a bug, it only happens when the storage of the tank is empty, that confused me a bit.

immibis
Filter Inserter
Filter Inserter
Posts: 303
Joined: Sun Mar 24, 2013 2:25 am
Contact:

Re: [0.9.0] Not sure if it is a bug (Control.lua, getliquid(

Post by immibis »

ficolas wrote:Ok sorry for tanking so long answering this.
Is not a bug, it only happens when the storage of the tank is empty, that confused me a bit.
Okay, that makes sense. When the tank is empty, there's no liquid in it. getliquid() returns nil to mean "no liquid" - otherwise it would have to specify a type.

Post Reply

Return to “Not a bug”