LuaBurner.currently_burning allows writing string too
Posted: Sun Nov 19, 2023 2:52 am
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):
but this does not work (errors with "Error: Given object is not lua item prototype.")
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"
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