Access prototypes in-game?

Place to get help with not working mods / modding interface.
immibis
Filter Inserter
Filter Inserter
Posts: 303
Joined: Sun Mar 24, 2013 2:25 am
Contact:

Access prototypes in-game?

Post by immibis »

Is there any way to access prototype data from in the game (i.e. control.lua)? Specifically, I need the recipe and technology prototypes. Entity and item prototypes are already available through game.entityprototypes and game.itemprototypes...
User avatar
AlexPhoenix
Fast Inserter
Fast Inserter
Posts: 149
Joined: Tue Feb 18, 2014 7:48 am
Contact:

Re: Access prototypes in-game?

Post by AlexPhoenix »

Code: Select all

game.player.force.recipes["repair-pack"]
somehow like this.
immibis
Filter Inserter
Filter Inserter
Posts: 303
Joined: Sun Mar 24, 2013 2:25 am
Contact:

Re: Access prototypes in-game?

Post by immibis »

AlexPhoenix wrote:

Code: Select all

game.player.force.recipes["repair-pack"]
somehow like this.
All you can do with that is see/set whether the recipe is enabled or not, and reload it.
ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: Access prototypes in-game?

Post by ficolas »

Same way as editing them drom the data.lua: data.raw.type.name where type and name are the the type (assembling machine, container, item, recipe etc) and the name is... The name!
So for example
data.raw.container["wooden-chest"]
But you cant edit them
immibis
Filter Inserter
Filter Inserter
Posts: 303
Joined: Sun Mar 24, 2013 2:25 am
Contact:

Re: Access prototypes in-game?

Post by immibis »

Image

Same thing happens when run from a control.lua script (as opposed to the console)
ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: Access prototypes in-game?

Post by ficolas »

Mmm yea Try with game.entityprototype or game.itemprototype.
Also try putting the type or directly the name.
immibis
Filter Inserter
Filter Inserter
Posts: 303
Joined: Sun Mar 24, 2013 2:25 am
Contact:

Re: Access prototypes in-game?

Post by immibis »

ficolas wrote:Mmm yea Try with game.entityprototype or game.itemprototype.
Also try putting the type or directly the name.
game.entityprototype and game.itemprototype are for entities and items. There's no game.recipeprototype, game.technologyprototype, recipe, or technology, nor the names of individual recipes or technologies:
Image
I already knew that, but I just tried them in the console for proof.

Same thing happens in 0.8.8 and 0.9.0.
Post Reply

Return to “Modding help”