Creating items inside a building

Place to get help with not working mods / modding interface.
Post Reply
starelf
Burner Inserter
Burner Inserter
Posts: 18
Joined: Mon Nov 17, 2014 4:44 am
Contact:

Creating items inside a building

Post 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?

User avatar
L0771
Filter Inserter
Filter Inserter
Posts: 516
Joined: Tue Jan 14, 2014 1:51 pm
Contact:

Re: Creating items inside a building

Post 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

starelf
Burner Inserter
Burner Inserter
Posts: 18
Joined: Mon Nov 17, 2014 4:44 am
Contact:

Re: Creating items inside a building

Post 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?

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Creating items inside a building

Post 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.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

starelf
Burner Inserter
Burner Inserter
Posts: 18
Joined: Mon Nov 17, 2014 4:44 am
Contact:

Re: Creating items inside a building

Post 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!

Post Reply

Return to “Modding help”