Spawning entities in biter bases on chunk-creation
-
- Fast Inserter
- Posts: 127
- Joined: Fri May 08, 2015 2:25 pm
- Contact:
Spawning entities in biter bases on chunk-creation
I have a mod idea that spawns so-called biter spires which provide free energy. I got this part done. The next step would be to make these entities spawn in biter bases on chunk-creation (I don't want more to spawn when the biters expand). However, I have no idea how to do that. As far as I can see it is related to autoplacing, but I have no idea how to do that in corellation with biter bases. Does anyone have an idea?
My RSO+Bob's+Angel's modpack: Farlands (outdated)
Mods (current): Resource Labels
Mods (old): Biter Spires
Mods (current): Resource Labels
Mods (old): Biter Spires
-
- Fast Inserter
- Posts: 127
- Joined: Fri May 08, 2015 2:25 pm
- Contact:
Re: Spawning entities in biter bases on chunk-creation
Sorry, but that was not helpful. I have looked through the API myself, that doesn't tell me how I can hook into the biter bases autoplacement.darkfrei wrote:http://lua-api.factorio.com/latest/even ... _generated
My RSO+Bob's+Angel's modpack: Farlands (outdated)
Mods (current): Resource Labels
Mods (old): Biter Spires
Mods (current): Resource Labels
Mods (old): Biter Spires
Re: Spawning entities in biter bases on chunk-creation
On the chunk generated, find all the biter bases in that newly generated chunk, and then spawn your entity in top of them, something like this:Pandemoneus wrote:Sorry, but that was not helpful. I have looked through the API myself, that doesn't tell me how I can hook into the biter bases autoplacement.darkfrei wrote:http://lua-api.factorio.com/latest/even ... _generated
Code: Select all
script.on_event(defines.events.on_chunk_generated, function(event)
local area = event.area
local surface = event.surface
for k, base in pairs (surface.find_entities_filtered{area = area, type = "unit-spawner"}) do
surface.create_entity{name = "your-entity", position = base.position, force = base.force}
end
end)
-
- Fast Inserter
- Posts: 127
- Joined: Fri May 08, 2015 2:25 pm
- Contact:
Re: Spawning entities in biter bases on chunk-creation
Thanks, but currently there is no way to do it directly together with the biter base autoplacement, right? I thought it would be possible to modify or add to that.Klonan wrote:On the chunk generated, find all the biter bases in that newly generated chunk, and then spawn your entity in top of them, something like this:
Code: Select all
script.on_event(defines.events.on_chunk_generated, function(event) local area = event.area local surface = event.surface for k, base in pairs (surface.find_entities_filtered{area = area, type = "unit-spawner"}) do surface.create_entity{name = "your-entity", position = base.position, force = base.force} end end)
My RSO+Bob's+Angel's modpack: Farlands (outdated)
Mods (current): Resource Labels
Mods (old): Biter Spires
Mods (current): Resource Labels
Mods (old): Biter Spires
Re: Spawning entities in biter bases on chunk-creation
No way currently, the game won't spawn entities which collide with one another in any casePandemoneus wrote:Thanks, but currently there is no way to do it directly together with the biter base autoplacement, right? I thought it would be possible to modify or add to that.Klonan wrote:On the chunk generated, find all the biter bases in that newly generated chunk, and then spawn your entity in top of them, something like this:
Code: Select all
script.on_event(defines.events.on_chunk_generated, function(event) local area = event.area local surface = event.surface for k, base in pairs (surface.find_entities_filtered{area = area, type = "unit-spawner"}) do surface.create_entity{name = "your-entity", position = base.position, force = base.force} end end)