[Solved] Remove "unlocking" of a recipe from a tecnology

Place to get help with not working mods / modding interface.
Post Reply
User avatar
laige
Long Handed Inserter
Long Handed Inserter
Posts: 66
Joined: Mon Oct 13, 2014 8:11 pm
Contact:

[Solved] Remove "unlocking" of a recipe from a tecnology

Post by laige »

Hi I am playing around making a mod.

I am trying to move smart inserters to a higher tech that unlocks the the recipe. Well I did that but now I need to remove it from the lower tech. This is what I have, but the removing part is throwing out errors. I'm not sure how this is incorrect though.

Code: Select all

--Moving Smart inserter to higher Technology
table.remove(data.raw.technology["electronics"].effects,{type = "unlock-recipe", recipe = "smart-inserter"})
table.insert(data.raw.technology["advanced-electronics"].effects,{type = "unlock-recipe", recipe = "smart-inserter"})
Last edited by laige on Mon Jun 15, 2015 2:49 pm, edited 1 time in total.

kds71
Long Handed Inserter
Long Handed Inserter
Posts: 91
Joined: Fri Mar 06, 2015 12:27 pm
Contact:

Re: Remove "unlocking" of a recipe from a tecnology

Post by kds71 »

table.remove takes a number as an argument, you have to pass index of entry you want to remove if you want to use it. Something like that should work:

Code: Select all

for i = 1, #data.raw.technology["electronics"].effects do
    effect = data.raw.technology["electronics"].effects[i]
    if effect.type == "unlock-recipe" and effect.recipe == "smart-inserter" then
        index = i
    end
end

table.remove(data.raw.technology["electronics"].effects, index)
but perhaps there is a better way.

User avatar
laige
Long Handed Inserter
Long Handed Inserter
Posts: 66
Joined: Mon Oct 13, 2014 8:11 pm
Contact:

Re: Remove "unlocking" of a recipe from a tecnology

Post by laige »

^^^
Thanks that works great.

Post Reply

Return to “Modding help”