Is it this?
Code: Select all
data.raw.technology['tech-name-here'].effects = table.append({
type = 'recipe', --or whatever type this is
name = 'name'
})
Code: Select all
data.raw.technology['tech-name-here'].effects = table.append({
type = 'recipe', --or whatever type this is
name = 'name'
})
Code: Select all
table.insert(data.raw["technology"]["tech-name"].effects, {type = "unlock-recipe",recipe = "item-name"}) --can only add one item
Take a look at bobs library mod - he created utility functions for stuff like this.bigyihsuan wrote:Question, is there a more efficient way of mass-adding items to existing researches other than just spamming table.insert(data.raw['technology']['tech-name'], {type = unlock-whatever', name = 'whatever'})?
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
ipairs iterates over integer keys in increasing order, starting from 1, stopping at the first missing one, ignoring all other keys in the table.bobingabout wrote: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.