Example:
I have created a new research to increase the output of the solar panel by 5% per level.
I have the research working.
But I am not able to increase the production value of the solar panel.
I have this code in control.lua
Code: Select all
script.on_event(defines.events.on_research_finished, function(event)
local research = event.research
-- Check if the finished research is related to solar panel efficiency
if research.name == "solar-panel-efficiency" then
-- Calculate the new power output based on the level of efficiency researched
local level = research.level
local new_output = 0.06 * (1 + (level * 0.1)) -- Base output is 60kW, which is 0.06MW, each level adds 10%
-- Update the production of all solar panels
for _, surface in pairs(game.surfaces) do
for _, panel in pairs(surface.find_entities_filtered{type="solar-panel"}) do
panel.production = new_output .. "MW" --Getting an error on this line.
end
end
end
end)
I have this code in data-updates.lua which works. But I wanted this to be a researched effect instead.
Code: Select all
data.raw["solar-panel"]["solar-panel"].production= "0.6MW" --For testing
Code: Select all
data:extend({
{
type = "technology",
name = "solar-panel-efficiency",
icon_size = 256,
icons = util.technology_icon_constant_stack_size("__base__/graphics/technology/solar-energy.png"),
effects = {},
prerequisites = {"solar-energy"},
unit =
{
count_formula = "((L*100)^2)",
ingredients =
{
{"military-science-pack", 1},
{"automation-science-pack", 1},
{"logistic-science-pack", 1},
{"chemical-science-pack", 1},
{"production-science-pack", 1},
{"utility-science-pack", 1},
{"space-science-pack", 1}
},
time = 30
},
upgrade = true,
max_level = "infinite",
order = "a-h-a"
}
})