local function copy_icon_specification_from_rhs(lhs, rhs) if rhs.icons then -- `icons` takes precdence over `icon` lhs.icons = rhs.icons lhs.icon_size = rhs.icon_size lhs.icon_mipmaps = rhs.icon_mipmaps return true end if rhs.icon then lhs.icon = rhs.icon lhs.icon_size = rhs.icon_size lhs.icon_mipmaps = rhs.icon_mipmaps return true end return false end local function map(t, f) -- TODO: Make this into an iterable somehow local res = {} for _, v in pairs(t) do table.insert(res, f(v)) end return res end local assembler = data.raw["assembling-machine"]["assembling-machine-3"] local new_assembler = { type = assembler.type, name = assembler.name .. "-new-assembler", crafting_categories = map(assembler.crafting_categories, function(e) return e .. "-phantom-machine" end), energy_usage = assembler.energy_usage, crafting_speed = assembler.crafting_speed, energy_source = assembler.energy_source, source_inventory_size = assembler.source_inventory_size, result_inventory_size = assembler.result_inventory_size, } copy_icon_specification_from_rhs(new_assembler, assembler) data.raw["recipe"]["processing-unit"].category = data.raw["recipe"]["processing-unit"].category .. "-phantom-machine" data:extend{new_assembler} for _, v in pairs(assembler.crafting_categories) do data:extend({ { type = "recipe-category", name = v .. "-phantom-machine" } }) end