Creating items inside a building
Creating items inside a building
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
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
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
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?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
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: Creating items inside a building
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
Where do I define a new category? I'm not sure how factorio defines categories and types, such as "type="laser-turret".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.
Edit: figured it out, looked in the factorio base files and found how to do it. Thanks!