Page 1 of 1

LuaBurner.currently_burning allows writing string too

Posted: Sun Nov 19, 2023 2:52 am
by Penguin_Spy
For LuaBurner.currently_burning, the type is indicated as read/write LuaItemPrototype. This is true, but the field also allows writing just the string of the item prototype's name. Note that the type is not ItemPrototypeIdentification, as that would allow writing a LuaItemStack too which LuaBurner.currently_burning does not allow.

Both of the following lines work (when hovering over a locomotive for example):

Code: Select all

game.player.selected.burner.currently_burning = game.item_prototypes["nuclear-fuel"]

game.player.selected.burner.currently_burning = "coal"
but this does not work (errors with "Error: Given object is not lua item prototype.")

Code: Select all

-- note: first slot of inventory is coal. this is just an easy way to get a LuaItemStack
item_stack = game.player.get_inventory(1)[1]
game.player.selected.burner.currently_burning = item_stack

Re: LuaBurner.currently_burning allows writing string too

Posted: Mon Jan 22, 2024 6:43 pm
by Stringweasel
Another little note, it's possible to set `currently_burning` to any fuel, regardless of the burner's fuel category.