I'm new on Factorio modding, and I wish you can help me to validate/correct this approach for my first mod:
I want to create a new assembly-machine item, that is also a small-electric-pole (with energy distribution and connection).
(ie: I want my custom-assembly-machine to share electricity 1 tile arround each side (so supply_area_distance=3 (from the middle)), and that connect with other electric-poles and custom-assembly-machines arround (maximum_wire_distance=xx). The top of this pylon (with its connections) must be visible
How would you achieve that?
I read couple guides and topics on this forum, and found the mod "Bio Industries" as example (more specificaly, the "bio_farm"). viewtopic.php?f=25&t=55518&p=326305&hil ... le#p326305
Regarding what I understood, I was thinking my needs:
Create prototype "assembly-machine-electric"
Copy the initial "assembly-machine-3",
change the recepe to add 1 small-electric-pole
Create prototype "assembly-machine-pole",
Copy of "small-electric-pole",
change values of its properties supply_area_distance and maximum_wire_distance
collision_box = {{-0, -0}, {0, 0}}
in control.lua:
when the assembling-machine-electric is built, automatically creates a assembling-machine-pole at the same position, and save it as a group_entities.
when the assembling-machine-electric is removed/destroyed, get the grouped assembling-machine-pole to destroy both.
Code: Select all
-- example with the on_built_entity
script.on_event(defines.events.on_built_entity)
local entity = event.created_entity
if entity.valid and entity.name == "assembling-machine-electric" then
local assembling_machine_electric = entity
local create_pole = surface.create_entity({name = "assembling-machine-pole" , position = entity.position, force = entity.force})
create_pole.minable = false
create_pole.destructible = false
group_entities(cantor(position.x,position.y), {assembling_machine_electric, create_pole})
end
end
* Prevent players to create the assembly-machine-pole directly
* Manage technology so assembly-machine-electric is allowed with the technology for classic assembly machine (in data-updates.lua or data-final-fixes.lua?)
* Manage the image(s?) of the assembly-machine-pole so the bottom on the pylon is transparent/removed (the part of the pylon that is supposed to be "in the assembly machine") (how can I manage which image is on top of the other one?)
Do you feel this is the correct approach ?
How would you do?
Did I miss something important?
Thank you for reading,