[SOLVED][Help] Lock item

Place to get help with not working mods / modding interface.
Post Reply
User avatar
dtoxic
Long Handed Inserter
Long Handed Inserter
Posts: 71
Joined: Fri Apr 01, 2016 8:40 pm
Contact:

[SOLVED][Help] Lock item

Post by dtoxic »

Hi all, could some one tell me how would i lock a recipe from another mod where the line reads "enable = true" (i want to lock it from start and enable it trough technology research witch i already done with the following line

table.insert(data.raw["technology"]["electric-machinery"].effects,{type = "unlock-recipe",recipe = "electric-stone-furnace"})

now i need to disable it from the very beginning of the game,i can achieve this by editing the mod directly but i would like to create my own set of tweaks in my mod with "table.insert" if possible to edit that specific line where it reads "enabled = true" to "enabled = false" i am using data-updates.lua to do this
Last edited by dtoxic on Wed Jan 25, 2023 3:06 pm, edited 1 time in total.

User avatar
dtoxic
Long Handed Inserter
Long Handed Inserter
Posts: 71
Joined: Fri Apr 01, 2016 8:40 pm
Contact:

Re: [Help] Lock item

Post by dtoxic »

so i manages to do it like this

if (mods or script.active_mods)["Electric Furnaces"] then
data:extend{
{
type = "recipe",
name = "electric-stone-furnace",
ingredients = {nil}, -- if leave it like this then no materials are required to craft this,if i put the default required materials then i get conflict with other mods on start
result = "electric-stone-furnace",
enabled = false, ----this is the only property i would like to change for this particular item in another mod from True to False
}
}
end

So any wizards here,please do cast your spells

Hornwitser
Fast Inserter
Fast Inserter
Posts: 201
Joined: Fri Oct 05, 2018 4:34 pm
Contact:

Re: [Help] Lock item

Post by Hornwitser »

You can access the tables of existing prototypes through data.raw. If I'm not mistaken then something like

Code: Select all

data.raw["recipe"]["electronic-stone-furnace"].enabled = false
should do what you want to achieve.

User avatar
dtoxic
Long Handed Inserter
Long Handed Inserter
Posts: 71
Joined: Fri Apr 01, 2016 8:40 pm
Contact:

Re: [Help] Lock item

Post by dtoxic »

thx for the input but this does not seem to work,and i belive this will not work since this is not a vanilla item it's from another mod...so the question is how access a item prototype data from another mod

Error ModManager.cpp:1560: Failed to load mod "Misc Tweaks": __Misc Tweaks__/data-final-fixes.lua:3: attempt to index field 'recipe' (a nil value)

robot256
Filter Inserter
Filter Inserter
Posts: 536
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: [Help] Lock item

Post by robot256 »

Hornwitser is right, that should work. Data.raw is shared between all the mods, so as long as the other mod has added their prototypes first, your mod can change them. Post your code that produced the error so we can help find where the issue is.

ichVII
Long Handed Inserter
Long Handed Inserter
Posts: 93
Joined: Mon Feb 27, 2017 10:16 pm
Contact:

Re: [Help] Lock item

Post by ichVII »

Is the recipe called "electronic-stone-funrace" or "electric-stone-furnace"? There seems to be inconsitency between previous posts in this thread.

I think Hornwizter misspelled the recipe and with the right spelling it should work.

User avatar
dtoxic
Long Handed Inserter
Long Handed Inserter
Posts: 71
Joined: Fri Apr 01, 2016 8:40 pm
Contact:

Re: [Help] Lock item

Post by dtoxic »

Yeap...i am blind officially! that was it...and here i was reading over tons of documentation to find what was wrong and the most simplest mistake goes unseen....hahahaah

Thx for noticing this you saved me from going insane!

User avatar
dtoxic
Long Handed Inserter
Long Handed Inserter
Posts: 71
Joined: Fri Apr 01, 2016 8:40 pm
Contact:

Re: [Help] Lock item

Post by dtoxic »

So here is now the working code if anyone else is in need of locking recipes for other mods

This one locks 2 items in the Electric Furnaces mod and moves them further down in the tech tree to a technology used by another mod called Early Extensions

Code: Select all

table.insert(data.raw["technology"]["electric-machinery"].effects,{type = "unlock-recipe",recipe = "electric-stone-furnace"})
table.insert(data.raw["technology"]["electric-machinery"].effects,{type = "unlock-recipe",recipe = "electric-boiler"})

data.raw["recipe"]["electric-stone-furnace"].enabled = false
data.raw["recipe"]["electric-boiler"].enabled = false
Thanks guys for all the help and @ichVII for your eyes

Post Reply

Return to “Modding help”