Discussion: multiple fluid tanks

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

Discussion: multiple fluid tanks

Post by immibis »

Since 0.9, entities can have multiple fluid tanks (internally called fluid boxes). For example: steam engines have one tank that has two connection points, amd chemical plants have up to four tanks and four connection points (the exact configuration depends on the recipe). The current Lua getliquid() function only allows read-only access to the contents of one tank. This needs to be extended to support access to any tank.

The problem is: how should we identify a specific tank to access?

Options:
  • Use a number. 0 is the first tank, 1 is the second tank, etc. Invalid indices either throw an error or return nil. getliquid(2) returns the 3rd tank.
    Pros: Easy to implement.
    Cons: Not very useful. You don't even know which tank you're accessing.
  • Use a string identifier set in the prototype. getliquid("input") returns the tank called "input".
    Pros: Easy to identify specific tanks - just pass the same string you set in the prototype.
    Cons: Requires prototypes to be updated. How to handle combined fluid boxes? (e.g. chemical plant has two input fluidboxes, but if you select a recipe with only one input they get merged)
  • Use a defines.fluidbox identifier, like getinventory(). getliquid(defines.fluidbox.input1) returns the first input tank.
    Pros: Special cases, like combined fluid boxes, can easily be handled separately.
    Cons: Requires prototypes to be updated. You can't define your own types of fluid boxes, like you could if they were strings.
  • Use a string identifier from the prototype, but allow multiple fluid boxes to have the same identifier. getliquid("input") returns a list of all input tanks.
    Pros: Combined fluid boxes work fine, as long as they have the same identifier - it just returns the combined fluid box instead of the individual ones.
    Cons: Requires prototypes to be updated. It's still hard to get a particular input.
  • Anything else I didn't think of.

Post Reply

Return to “Implemented mod requests”