Using Lua API global Variable Viewer, the recipes in force don't contain "icon" even though the recipe Prototype definition does? Then how is it possible to retrieve the icon of a recipe, and making it mod compatible. Looping through force.recipes really seems to be the way, since that contains all recipes in the whole game, modded included.
Code snippet of my loop (currently set up to only print the icon of the recipe):
Code: Select all
function build_sprite_buttons(player)
local button_table = player.gui.screen["cc_configWindow"].cc_contentFrame.button_frame.button_table
button_table.clear()
for _, recipe in pairs(player.force.recipes) do
game.print(tostring(recipe.icon))
end
end
Error while running event crafting_cleanup::on_player_created (ID 26)
LuaRecipe doesn't contain key icon.
stack traceback:
[C]: in function '__index'
__crafting_cleanup__/control.lua:134: in function 'build_sprite_buttons'
__crafting_cleanup__/control.lua:246: in function 'createConfigWindow'
__crafting_cleanup__/control.lua:259: in function <__crafting_cleanup__/control.lua:250>