diff --git a/src/api.lua b/src/api.lua index 70b20d8..d2e9cfb 100644 --- a/src/api.lua +++ b/src/api.lua @@ -45,7 +45,17 @@ end local function setup_item(item_name, target_quality) if data.raw.item["qrc-"..target_quality.."-"..item_name] then return end - local item = table.deepcopy(data.raw.item[item_name]) + -- Check if the item is a module, since modules are not in data.raw.item but instead in data.raw.module + local item = nil + if string.find(item_name, "-module") then + item = table.deepcopy(data.raw.module[item_name]) + else + item = table.deepcopy(data.raw.item[item_name]) + end + + if not item then + error("Couldn't find item " .. item_name .. " in data.raw!") + end make_icon(item, target_quality) diff --git a/src/control.lua b/src/control.lua index 688ea13..eff1e5e 100644 --- a/src/control.lua +++ b/src/control.lua @@ -89,6 +89,12 @@ script.on_event("on_tick", function() if player.opened then local entity = player.opened if not entity then return end + + -- also check if the player opened the equipment grid to avoid a crash + if entity.object_name == "LuaEquipmentGrid" then + return + end + if entity.type == "assembling-machine" or (entity.type == "entity-ghost" and entity.ghost_type == "assembling-machine") then check_machine_quality(entity) end