I have learned a couple of things with the codes of others, but there is something that I still cannot understand and I need help.
I am creating a new solar panel, and in the recipes I see that:
1. The ingredients do not decomposes completely.
2. The recipe is not blocked by research, as the original does.
Original
New
Code: Select all
-- solar-panel.lua
local lib = require("lib")
if not lib.mods.solar_panel.Multiplier == 1 then return nil end
for _, Base in pairs( lib.mods.solar_panel.base ) do
local Name = lib.prefix .. Base
local Multiplier = lib.mods.solar_panel.Multiplier
local Entity = table.deepcopy( data.raw[ "solar-panel" ][ Base ] ) -- Copia la entidad
Entity.localised_description = { "zzYaim-descriptions", { "entity-description." .. Base } }
Entity.localised_name = { "zzYaim-names", { "entity-name." .. Base }, Multiplier }
Entity.minable.resul = Name
Entity.name = Name
local Production = { }
Production.string = Entity.production
Production.value = lib.getNumber( Production.string )
Production.unit = lib.getUnit( Production.string )
Production.value = Production.value * Multiplier
Production.string = lib.toString( Production.value )
Production.string = Production.string .. Production.unit
Entity.production = Production.string
local Item = table.deepcopy( data.raw[ "item" ][ Base ] ) -- Copia el objeto
Item.place_result = Name
Item.name = Name
local Recipe = table.deepcopy( data.raw[ "recipe" ][ Base ] ) -- Copia la receta
Recipe.energy_required = Recipe.energy_required * Multiplier
Recipe.allow_decomposition = true
Recipe.ingredients = { }
Recipe.enabled = true
Recipe.result = Name
Recipe.name = Name
local Ingredients = { { item = Base }, { item = "processing-unit" }, { item = "raw-fish" } }
for _, ingredient in pairs( Ingredients ) do
for type, name in pairs( ingredient ) do
local Ingredient = { }
Ingredient.name = name
Ingredient.type = type
Ingredient.amount = Multiplier
table.insert( Recipe.ingredients, Ingredient )
end
end
-- Ubico la tecnología
local t = data.raw[ "technology" ][ "solar-energy" ]
table.insert( t.effects, { type = "unlock-recipe", recipe = Name } )
data:extend( { Entity, Item, Recipe } )
end