Page 1 of 1

Access prototypes in-game?

Posted: Wed Feb 19, 2014 3:22 am
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...

Re: Access prototypes in-game?

Posted: Wed Feb 19, 2014 6:20 am
by AlexPhoenix

Code: Select all

game.player.force.recipes["repair-pack"]
somehow like this.

Re: Access prototypes in-game?

Posted: Wed Feb 19, 2014 10:10 am
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.

Re: Access prototypes in-game?

Posted: Wed Feb 19, 2014 2:44 pm
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

Re: Access prototypes in-game?

Posted: Wed Feb 19, 2014 10:21 pm
by immibis
Image

Same thing happens when run from a control.lua script (as opposed to the console)

Re: Access prototypes in-game?

Posted: Wed Feb 19, 2014 10:43 pm
by ficolas
Mmm yea Try with game.entityprototype or game.itemprototype.
Also try putting the type or directly the name.

Re: Access prototypes in-game?

Posted: Thu Feb 20, 2014 2:54 am
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.