I want some help please to understand lua & the Factorio API a bit better...
I wanted my mod to change one of the icons for the blueprint held in the hand.
The current blueprint icon is an item = "iron-plate" and I want to change it to "pipe", so I thought I could just do this:
Code: Select all
player.cursor_stack.blueprint_icons[1].signal.name = "pipe"
I initially thought it might be related to this bug report: [0.15.3] Cannot set blueprint_icons
After much trial and error (and cussing) I got it working like this:
Code: Select all
local blueprintIcons = player.cursor_stack.blueprint_icons
blueprintIcons[1].signal.name = "pipe"
player.cursor_stack.blueprint_icons = blueprintIcons
Looking at LuaItemStack.blueprint_icons in the Factorio API, it shows:
Does the "array of" signify anything? I understood lua arrays are just tables?blueprint_icons :: array of Icon [Read-Write]
Icons of a blueprint item. Every entry of this array has the following fields:
signal :: SignalID: Slot icon to use. The slot will have the icon of the specified signal. This allows the use of any item icon, as well as virtual signal icons.
index :: uint: Index of the icon in the blueprint icons slots. Has to be in {1, 2, 3, 4}.
Can only be used if this is BlueprintItem
I've got it all working now, but would love to understand why!!