I'm making a battery mod as my first mod, just to get used to modding. I want entities that use electricity (such as electric mining drills) to be able use batteries, like burner items use fuel/coal/wood. The general idea is to have a 1x1 machine that you put batteries in which would have tiers like assembling machines, like a Power Generator/Supplier (haven't decided on the name yet) 1 which would have 2 battery slots, 2 which would have 4, and 3 which would have 6 battery slots. You would then connect copper wire to the generator, and then to a pole to supply it with electricity, which you would then place an electric object within range of the pole. So basically, an alternative to steam/solar electricity. There would be different tiers of batteries measured in watts, such as a 50 kW battery, 75 kW battery, 100 kW, 200 kW, and so on, with the top tier likely being 500 kW.
The only problem with it is that I have no clue how I would make the generator entity or make it generate electricity. Can anyone help me with making something like this? I can provide extra info if needed.
Need some advice/tips for making my first mod
-
- Burner Inserter
- Posts: 16
- Joined: Mon Jan 02, 2017 12:09 pm
- Contact:
Re: Need some advice/tips for making my first mod
Custom power sources are complicated. There is no simple way to define them, you need to do most of the work in a Lua script.
data.lua:
Define 2 entities. One with type="accumulator", one with type="container".
control.lua:
on_built_entity, on_robot_built_entity: If the item is your custom accumulator, create your custom container too.
on_tick: Read the contents of the container, destroy any batteries you find, and increase the energy level of the accumulator.
data.lua:
Define 2 entities. One with type="accumulator", one with type="container".
control.lua:
on_built_entity, on_robot_built_entity: If the item is your custom accumulator, create your custom container too.
on_tick: Read the contents of the container, destroy any batteries you find, and increase the energy level of the accumulator.
Re: Need some advice/tips for making my first mod
The "electric-energy-interface" type entity can produce or consume power at demand with any of it's energy properties being adjustable runtime through the Lua API: http://lua-api.factorio.com/latest/LuaE ... production
If you want to get ahold of me I'm almost always on Discord.
Re: Need some advice/tips for making my first mod
So, where's any documentation on that type? Which fields are required in prototypes and such.Rseding91 wrote:The "electric-energy-interface" type entity can produce or consume power at demand with any of it's energy properties being adjustable runtime through the Lua API: http://lua-api.factorio.com/latest/LuaE ... production
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.
I also update mods, some of them even work.
Recently I did a mod tutorial.
Re: Need some advice/tips for making my first mod
Theres an electric-energy-interface defined in the base mod, and the api for it is in LuaEntityAdil wrote:So, where's any documentation on that type? Which fields are required in prototypes and such.Rseding91 wrote:The "electric-energy-interface" type entity can produce or consume power at demand with any of it's energy properties being adjustable runtime through the Lua API: http://lua-api.factorio.com/latest/LuaE ... production
Re: Need some advice/tips for making my first mod
Oh, okay, I did search wrong name first.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.
I also update mods, some of them even work.
Recently I did a mod tutorial.
-
- Burner Inserter
- Posts: 16
- Joined: Mon Jan 02, 2017 12:09 pm
- Contact:
Re: Need some advice/tips for making my first mod
Thanks for the link! I'm understanding it a bit better now, thankfully. To add the slots, would I have to look at code for, say, a furnace, and then base it off of that (combined with the accumulator code)?Rseding91 wrote:The "electric-energy-interface" type entity can produce or consume power at demand with any of it's energy properties being adjustable runtime through the Lua API: http://lua-api.factorio.com/latest/LuaE ... production
-
- Burner Inserter
- Posts: 16
- Joined: Mon Jan 02, 2017 12:09 pm
- Contact:
Re: Need some advice/tips for making my first mod
I hope you don't mind me asking, but could you explain this a bit more? I'm not sure how to define entities inside of the data.lua, so far it just has the require functions in it.DaveMcW wrote:Custom power sources are complicated. There is no simple way to define them, you need to do most of the work in a Lua script.
data.lua:
Define 2 entities. One with type="accumulator", one with type="container".
control.lua:
on_built_entity, on_robot_built_entity: If the item is your custom accumulator, create your custom container too.
on_tick: Read the contents of the container, destroy any batteries you find, and increase the energy level of the accumulator.
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: Need some advice/tips for making my first mod
Look at any of the mods in the portal - most define entities (often they will have several files in a /prototypes folder, and then the data.lua includes those files). You will often need recipes and items as well.
Also, it's worth reading this to get an idea of how everything fits together: http://lua-api.factorio.com/latest/Data-Lifecycle.html
Also, it's worth reading this to get an idea of how everything fits together: http://lua-api.factorio.com/latest/Data-Lifecycle.html
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.