crafting_categories

Place to get help with not working mods / modding interface.
User avatar
L0771
Filter Inserter
Filter Inserter
Posts: 516
Joined: Tue Jan 14, 2014 1:51 pm
Contact:

crafting_categories

Post by L0771 »

Hi, i want add a new crafting_categories in the player, i think it is basic, but it not returned an error and it not work

Code: Select all

for _,v in ipairs(data.raw.player) do
	v.crafting_categories[#crafting_categories + 1] = {"cursed-nocraftmachine"}
end
User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: crafting_categories

Post by rk84 »

Loop is unnecessary if you want to edit just single player prototype (the one that is used as default for all players) and data.raw's type and name tables are not arrays.

Code: Select all

local player = data.raw.player.player
player.crafting_categories[#player.crafting_categories + 1] = "cursed-nocraftmachine" -- this should result {"crafting","cursed-nocraftmachine"} in player.crafting_categories
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela
User avatar
L0771
Filter Inserter
Filter Inserter
Posts: 516
Joined: Tue Jan 14, 2014 1:51 pm
Contact:

Re: crafting_categories

Post by L0771 »

Thanks you! it works!

but if a mod edit this player or have some added players?
User avatar
rk84
Filter Inserter
Filter Inserter
Posts: 556
Joined: Wed Feb 13, 2013 9:15 am
Contact:

Re: crafting_categories

Post by rk84 »

L0771 wrote:Thanks you! it works!

but if a mod edit this player or have some added players?
There should not be conflict if another mod edits the crafting_categories same way as above or uses table.insert()

For additional player prototypes you could use your code (I fixed 3 things).

Code: Select all

for _,v in pairs(data.raw.player) do
   v.crafting_categories[#v.crafting_categories + 1] = "cursed-nocraftmachine"
end
Test mode
Searching Flashlight
[WIP]Fluid handling expansion
[WIP]PvP gamescript
[WIP]Rocket Express
Autofill: The torch has been pass to Nexela
Post Reply

Return to “Modding help”