Page 1 of 1
Entity with inventory, energy consumption and supply area
Posted: Wed May 13, 2020 5:20 pm
by ODAEL
Hi there!
I want to create mod for something like Transport cannon - entity which can make long-distance transporting, or "teleporting" of items.
So, I want to create entity with inventory, energy consumption and supply area - the maximum range of transporting.
The abstract question is - how can I "add" some of those features to another entity? Can I add an energy consumption for container or replace roboport's inventory with "container-like" inventory?
Re: Entity with inventory, energy consumption and supply area
Posted: Wed May 13, 2020 8:53 pm
by Impatient
ODAEL wrote: Wed May 13, 2020 5:20 pm
...
The abstract question is - how can I "add" some of those features to another entity? ...
ODAEL wrote: Wed May 13, 2020 5:20 pm
... Can I add an energy consumption for container or replace roboport's inventory with "container-like" inventory?
No, you can not do stuff like that in factorio modding. Factorio modding is not like extending the core game code. The core game code is sealed behind what is presented to you in the modding API. It is not changeable in any way.
And that modular aproach you are thinking of is also nothing factorio offers.
What can be done is:
1. You can define new prototypes for entities before a game start by changing the values of exiting prototypes (but just values, and you can not introduce new properties and logic )
2. You can change values of entities in game (by which you can sort of make them appear to the player to behave differently)
3. You have a scripting language available where you can implement the full logic for the behavior you want and do, by which you can do (2.)
But you can not create your own code for new prototypes and you can not take parts of existing prototypes and piece them together.
If that does not scare you off, then read on.
They way to achieve something in factorio modding is this:
- First you will have a look around, what available prototypes feature what parts of your idea (an inventory, a power sink, a cannon, etc ...) and offer what values to change. ... this part is very tough for beginners, because they simply just have a vague idea or no knowledge at all.
- Then you study what values of entities of some interesting prototypes can be changed in-game
- Based on that you select one or several prototypes you are going to (mis)use to implement your idea.
- You will use one of those prototypes to define one new prototype to implement the graphics and sounds you want (if you want new grpahics and sounds for your entities)
- Then you will write the logic in the scripting language and sort of "glue" entities of the prototypes you selected together (glue together = constantly change values of their properties in-game as needed, to implement the behavior you want) so that all put together your idea appears in the game.
Edit: In this answer I initiall went full rant against the way Factorio modding works and LUA as programming language. It was fun to me but later I felt it was not an appropriate answer to ODAEL 's question, but merely something I would chat about with the developers. So I removed that and replaced it with a more to the point answer.
Re: Entity with inventory, energy consumption and supply area
Posted: Wed May 13, 2020 9:01 pm
by Impatient
Mod miniloader does some nice magic the factorio modding way with existing prototypes but creates something new and very popular. Have a look at it
https://mods.factorio.com/mod/miniloader
But probably your head will spin because of all the "glue" scripting that is necessary to achieve this.
Re: Entity with inventory, energy consumption and supply area
Posted: Wed May 13, 2020 11:26 pm
by Klonan
ODAEL wrote: Wed May 13, 2020 5:20 pm
Hi there!
I want to create mod for something like Transport cannon - entity which can make long-distance transporting, or "teleporting" of items.
So, I want to create entity with inventory, energy consumption and supply area - the maximum range of transporting.
The abstract question is - how can I "add" some of those features to another entity? Can I add an energy consumption for container or replace roboport's inventory with "container-like" inventory?
Furnaces can have inventory and energy consumption
Also any entity can have a 'supply area' with the radius visualisation:
https://wiki.factorio.com/Prototype/Ent ... cification
Re: Entity with inventory, energy consumption and supply area
Posted: Fri May 15, 2020 11:09 am
by ODAEL
Thank you all, guys!
Impatient wrote: Wed May 13, 2020 8:53 pm
They way to achieve something in factorio modding is this:
- First you will have a look around, what available prototypes feature what parts of your idea (an inventory, a power sink, a cannon, etc ...) and offer what values to change. ... this part is very tough for beginners, because they simply just have a vague idea or no knowledge at all.
- Then you study what values of entities of some interesting prototypes can be changed in-game
- Based on that you select one or several prototypes you are going to (mis)use to implement your idea.
- You will use one of those prototypes to define one new prototype to implement the graphics and sounds you want (if you want new grpahics and sounds for your entities)
- Then you will write the logic in the scripting language and sort of "glue" entities of the prototypes you selected together (glue together = constantly change values of their properties in-game as needed, to implement the behavior you want) so that all put together your idea appears in the game.
Could you give some more info about last point? What exactly do you mean with "gluing" entities?
Impatient wrote: Wed May 13, 2020 9:01 pm
Mod miniloader does some nice magic the factorio modding way with existing prototypes but creates something new and very popular.
Maybe, this will be good example of magic "gluing" of entities functions. Thank you, I will try to get some tips from mod's code!
Oh, thanks! I forgot about furnace.
And hint about radius visualisation is very useful!
I got the main idea about limitations of Facorio modding. They are quite strict, but it is what it is.
Re: Entity with inventory, energy consumption and supply area
Posted: Fri May 15, 2020 11:12 am
by ODAEL
Impatient wrote: Wed May 13, 2020 8:53 pm
Edit: In this answer I initiall went full rant against the way Factorio modding works and LUA as programming language. It was fun to me but later I felt it was not an appropriate answer to ODAEL 's question, but merely something I would chat about with the developers. So I removed that and replaced it with a more to the point answer.
It is pretty familiar thing for programmers, I understand you)