crafting category for the player

Place to post guides, observations, things related to modding that are not mods themselves.
Post Reply
judos
Filter Inserter
Filter Inserter
Posts: 266
Joined: Mon Dec 08, 2014 11:17 am
Contact:

crafting category for the player

Post by judos »

Hello there,

I want to add a crafting category also for the player. Right now I have a modded a small machine (packager) which should not show all other recipes, therefore I started using a crafting_category. Now I also want the player to be able to craft the same recipes.

The following I found online, but it seems not to be working:

Code: Select all

table.insert(data.raw["player"]["crafting_categories"],"packager-pack")
"packager-pack" would be the new crafting category.

Thanks for your help!
cheers,
judos

cartmen180
Filter Inserter
Filter Inserter
Posts: 358
Joined: Fri Jul 25, 2014 2:53 pm
Contact:

Re: crafting category for the player

Post by cartmen180 »

try this:

Code: Select all

table.insert(data.raw["player"]["player"].crafting_categories,"packager-pack")
Check out my mods

User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: crafting category for the player

Post by Adil »

Did you package machine work as expected?
Are recipes researched/enabled?
There seems nothing wrong with the code listed.
You may try temporarily putting that right into player definition on base. If they don't appear after that, then something is wrong with recipes or category.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.

judos
Filter Inserter
Filter Inserter
Posts: 266
Joined: Mon Dec 08, 2014 11:17 am
Contact:

Re: crafting category for the player

Post by judos »

Nice this works. At least when I'm not in ghost mode (I used this to check my mod items etc.) Is it possible to connect the character again to the player perspective?

Code: Select all

table.insert(data.raw["player"]["player"].crafting_categories,"packager-pack")
Does this also work for multiplayer?
I right now have this one line at the beginning of my entity.lua file before the data:extend(..).

cartmen180
Filter Inserter
Filter Inserter
Posts: 358
Joined: Fri Jul 25, 2014 2:53 pm
Contact:

Re: crafting category for the player

Post by cartmen180 »

Adil wrote: There seems nothing wrong with the code listed.
In the first brackets you specify a 'type' and in the second brackets you specify the 'name' of that type. Otherwise the game doesn't know what to adjust.

@Judos I don't know if it works in multiplayer, you will have to try it out. Report your results back here please :)
Check out my mods

judos
Filter Inserter
Filter Inserter
Posts: 266
Joined: Mon Dec 08, 2014 11:17 am
Contact:

Re: crafting category for the player

Post by judos »

I played the mod several days on a server and it works nicely.
Probably this is because the command changes the prototype of the player even before any instances are created and therefore it will be used for any player.

Problem is solved :)

Post Reply

Return to “Modding discussion”