[Factorio 0.11] Introducing LuaFluidBox (liquid interaction)
Posted: Tue Nov 04, 2014 6:21 pm
Factorio 0.11.x expands the oppertunities how mods can interact with fluid.
I want to give you a short explanation what's new or was changed.
First off the getliquid() method is gone.
You now gain read/write access via the someEntity.fluidbox, where fluidbox is a table
Each table-entry represents always 1 type of liquid. So the size of the table is bound to the current number of different fluids the entity can hold.
E.g. pipes, steam-engines, tanks always have just one entry, because they can only contain one type of fluid at a time.
Whereas the number of fluidboxes of assembling-machines, refineries etc. can vary depending on the selected recipe.
You can use
to receive the number of fluidboxes for this entity.
For read-access you can simply use
fluidbox[1] returns a table with the following structure:
Write-access works analog:
where aFluid has to follow the table-structure described above.
But with the difference that the temperature is optional. If not defined the temperature is set to the default (specified in the prtotype). If the temperature is higher than the max temperature (again defined in the prototype) it is clamped to the max temperature.
Actually I believe that's all you have to know. Let me know if anything is unclear.
I want to give you a short explanation what's new or was changed.
First off the getliquid() method is gone.
You now gain read/write access via the someEntity.fluidbox, where fluidbox is a table
Each table-entry represents always 1 type of liquid. So the size of the table is bound to the current number of different fluids the entity can hold.
E.g. pipes, steam-engines, tanks always have just one entry, because they can only contain one type of fluid at a time.
Whereas the number of fluidboxes of assembling-machines, refineries etc. can vary depending on the selected recipe.
You can use
Code: Select all
#SomeEntity.fluidbox
For read-access you can simply use
Code: Select all
firstLiquid = SomeEntity.fluidbox[1]
Code: Select all
{
name = the fluid's name,
amount = the current amount,
temperature = well the current temperature;)
}
Code: Select all
SomeEntity.fluidbox[1] = aFluid
But with the difference that the temperature is optional. If not defined the temperature is set to the default (specified in the prtotype). If the temperature is higher than the max temperature (again defined in the prototype) it is clamped to the max temperature.
Actually I believe that's all you have to know. Let me know if anything is unclear.