Page 1 of 1
Creating items inside a building
Posted: Mon Nov 17, 2014 4:48 am
by starelf
Basically what I'm trying to do is, a building will generate an item using energy, and place the item into its inventory. I can't find the "type" declarations, like the "type=ammo" which I think is what I would have to edit. No items right now do anything like this. Help?
Re: Creating items inside a building
Posted: Mon Nov 17, 2014 5:32 am
by L0771
You need a entity where you can store items and use energy, maybe with [type = "assembling-machine"] or [type = "furnace"] (like electric furnace) and edit that entity.
With [entity].
getinventory(defines.inventory.assemblingmachineoutput).insert{name="steel-plate",count=5} you can insert a item in output slot and with [entity].
energy you can get actually energy and set a new energy
Re: Creating items inside a building
Posted: Mon Nov 17, 2014 6:39 am
by starelf
L0771 wrote:You need a entity where you can store items and use energy, maybe with [type = "assembling-machine"] or [type = "furnace"] (like electric furnace) and edit that entity.
With [entity].
getinventory(defines.inventory.assemblingmachineoutput).insert{name="steel-plate",count=5} you can insert a item in output slot and with [entity].
energy you can get actually energy and set a new energy
I was thinking of doing that, but how in the script do I reference the entity? I was thinking something like this.energy, but I can't figure out how to self-reference. Also, I'm putting the lua scripts in control.lua, correct?
Re: Creating items inside a building
Posted: Mon Nov 17, 2014 9:09 am
by bobingabout
You can actually do such a thing without scripting. Create a new Assembly Machine entity, with a unique Recipe Catagory, then create a recipe with no ingredients listed, setting the Catagory to that of the new assembly machine. Don't forget to define the new catagory too. when you place the machine in game, choose the new recipe, and the assembly machine will build your item without needing any ingredients.
Re: Creating items inside a building
Posted: Mon Nov 17, 2014 10:20 pm
by starelf
bobingabout wrote:You can actually do such a thing without scripting. Create a new Assembly Machine entity, with a unique Recipe Catagory, then create a recipe with no ingredients listed, setting the Catagory to that of the new assembly machine. Don't forget to define the new catagory too. when you place the machine in game, choose the new recipe, and the assembly machine will build your item without needing any ingredients.
Where do I define a new category? I'm not sure how factorio defines categories and types, such as "type="laser-turret".
Edit: figured it out, looked in the factorio base files and found how to do it. Thanks!