[Scripting Assistance] Trying to set dynamically generated techs to unlocked by default
Posted: Wed Dec 22, 2021 4:18 am
Hello once again. Since my last post and all the help I've gotten there, I've started on a new project which is going well so far. It's going to be an addon for Beekeeping 2 which enables all bee techs from the beginning, and adjusts recipes such that it can be used to start up in a seablock-style/no resource world. All's been well until I started looking at the dynamically created ore bee techs, which all have a prefixed beekeeping name, with the species name added on based on the ores present in a given game. I.E. bee-technology-[Ore Name] I'm not sure how to reference those techs in the unlock function. What I have so far:
Code: Select all
local function main(e)
if game.active_mods["NPBees2"] then
for _, force in pairs(game.forces) do
if settings.startup["Starting-Bees"] and settings.startup["Starting-Bees"].value == true then
force.technologies["beekeeping-1"].researched = true
force.technologies["beekeeping-2"].researched = true
force.technologies["bee-technology-"].researched = true <-- This is the part causing nil errors on world start/load
end
end
end
end
local function player_created(e)
main(e)
end
local function cutscene_cancelled(e)
if remote.interfaces["freeplay"] then
main(e)
end
end
script.on_event(defines.events.on_player_created,player_created)
script.on_event(defines.events.on_cutscene_cancelled,cutscene_cancelled)