Page 1 of 1

[SOLVED][Help] Lock item

Posted: Tue Jan 24, 2023 10:33 pm
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

Re: [Help] Lock item

Posted: Wed Jan 25, 2023 12:21 am
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

Re: [Help] Lock item

Posted: Wed Jan 25, 2023 1:05 am
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.

Re: [Help] Lock item

Posted: Wed Jan 25, 2023 9:04 am
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)

Re: [Help] Lock item

Posted: Wed Jan 25, 2023 12:58 pm
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.

Re: [Help] Lock item

Posted: Wed Jan 25, 2023 1:13 pm
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.

Re: [Help] Lock item

Posted: Wed Jan 25, 2023 1:23 pm
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!

Re: [Help] Lock item

Posted: Wed Jan 25, 2023 1:34 pm
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