I'm trying to figure out how to mod objects. I've been attempting something I thought would be simple - making lamps a power source with a supply area [before adding fuel slots and consumption]. I've tried copying code from the steam engine and from electric poles but it's ignored in-game. I assume it's because lamps aren't the same type of object but I don't see where type="lamp" is defined so that I can add "supply_area_distance", "radius_visualisation_picture" and so on to a lamp type object.
Is it even possible to add both properties to a lamp? If it is any help would be appreciated!
[Modding help] Adding power output and supply area to lamp
-
- Manual Inserter
- Posts: 1
- Joined: Sun Jan 08, 2017 7:13 pm
- Contact:
Re: [Modding help] Adding power output and supply area to lamp
Unluckily no, each entity has a fixed set of properties it uses and ignores the rest.kamikazehighland wrote:Is it even possible to add both properties to a lamp? If it is any help would be appreciated!
What mods usually do is create additional hidden entities to combine their functionalities. So in your case you would have:
- lamp entity: to produce light
- electric pole entity: to have electric supply area
- steam engine entity: to produce power
The script events you need to handle are:
Code: Select all
script.on_event(defines.events.on_robot_built_entity, function(event) OnBuilt(event.created_entity) end)
script.on_event(defines.events.on_built_entity, function(event) OnBuilt(event.created_entity) end)
script.on_event(defines.events.on_preplayer_mined_item, function(event) OnRemoved(event.entity) end)
script.on_event(defines.events.on_robot_pre_mined, function(event) OnRemoved(event.entity) end)
script.on_event(defines.events.on_entity_died, function(event) OnRemoved(event.entity) end)
Re: [Modding help] Adding power output and supply area to lamp
There is a mod: https://mods.factorio.com/mods/Klonan/Torches
look at the code and see if you can add an electric pole
look at the code and see if you can add an electric pole