My library does need a lot of new things adding to it, but yes, it does allow easier ways to add items to technologies.
One thing that my library doesn't do though, but you can look at my mods as an example is...
Migration scripts!!!
Adding a new unlock to a technology is fine, but when you load an old save where the research is already unlocked, you'll find the item is not... For this, you need to write a migration script.
I don't currently have access to code, but it would look something like...
Code: Select all
for i, force in ipairs (game.forces) do
if force.technology["technologyname"].researched == true then
force.recipe["recipename"].enabled = true
end
end
Like I said, no reference material to work from, that's off the top of my head, so is probably wrong.
You'd put that in the mod's migrations folder, with a name of your mod, with version number, .lua.
Note... what's the difference between pairs and ipairs?
ipairs will give the number from an indexed list in the first variable, followed by the directly usable address of the item (the whole force table of information in this case)
pairs works best if the table being iterated are tags with an = in them, they separate at the =, everything left of it is taken to be the element name and returned as the first variable, and everything on the right as the second variable.