Page 1 of 1

[2.1.9] LuaEntity::get_fluid_filter errors when trying to query fluid-wagon

Posted: Thu Jul 02, 2026 12:19 am
by Shemp
Fluid wagons have a fluids_count of 1, and it's usually safe to run get_fluid_* functions on an entity if their fluids_count is positive and the provided index falls within the bounds. (And get_fluid_segment_* functions are safe if you check that has_fluid_segment() is true.)

You can reproduce this error by doing the following:
  • Place a Fluid wagon in the world
  • Hover over the wagon with the mouse and run the following command
  • /c game.print(game.player.selected.fluids_count)
  • to verify the wagon's fluids_count = 1, and then run
  • /c filter = game.player.selected.get_fluid_filter(1)
This will print:
Error: Entity "fluid-wagon", (fluid-wagon) does not have fluids.

I expect the function to return nil.

Similarly, you also produce the error by calling set_fluid_filter. I would expect this function to silently fail as it does in cases, such as crafting machines, where a filter can't be set.

----------------------

EDIT: I'll also mention that this error does not occur on Flamethrower turrets. These have a fluids_count = 2, the second of which is an internal buffer with no associated FluidBox prototype.

Re: [2.1.9] LuaEntity::get_fluid_filter errors when trying to query fluid-wagon

Posted: Thu Jul 02, 2026 6:22 pm
by Rseding91
Thanks for the report. This is now fixed for the next release.