Code (which adds the Categories/SubCategories):
Code: Select all
local RocketItemCategory = table.deepcopy(data.raw['item-group']['production'])
RocketItemCategory.name = 'mrw:rocket-construction'
RocketItemCategory.icon = '__base__/graphics/icons/rocket-part.png'
RocketItemCategory.icon_size = 64
RocketItemCategory.icon_mipmaps = 4
RocketItemCategory.order = 'e'
data:extend({RocketItemCategory})
local RocketPartSubCategory = table.deepcopy(data.raw['item-subgroup']['space-related'])
RocketPartSubCategory.name = 'mrw:rocket-parts'
RocketPartSubCategory.group = 'mrw:rocket-construction'
RocketPartSubCategory.order = 'a'
data:extend({RocketPartSubCategory})
This is the code which makes some recipes and then adds it to the above SubCategory (It also makes items):
Code: Select all
function DefineRocketPart(name, ingredients, failure_chance)
name = 'mrw:' .. name
if data.raw['technology']['mrw:rocket-part-assembly'] == nil then
CreateTechnologies('RPA')
end
local Item = table.deepcopy(data.raw['item']['rocket-part'])
Item.name = name
data:extend({Item})
local Recipe = table.deepcopy(data.raw['recipe']['rocket-part'])
Recipe.name = name
Recipe.ingredients = ingredients
Recipe.result = nil
Recipe.result_count = nil
Recipe.normal = nil
Recipe.expensive = nil
Recipe.results = {{type = 'item', name = name, amount = 1, probability = 1 - failure_chance}}
for i, ingredient in pairs(ingredients) do
ingredient.probability = failure_chance
table.insert(Recipe.results, ingredient)
end
Recipe.main_product = name
Recipe.subgroup = 'mrw:rocket-parts'
data:extend({Recipe})
end