This sounds like an interesting mod. DivOresity only swaps existing ores on the surface. It only creates ores as replacements for other ores. If those ores are disabled, they should not be valid candidates to be used as replacements. And if no ores spawn at all, then there won't be anything for divOresity to do!
Thanks for the explanation! I haven't played around with the advanced things one can do with surfaces yet because I just needed a place to hide my entities. So the way I create surfaces is rather simple, very roughly like this:
if not game.surfaces[name] and game.surfaces[name].valid then
surface = game.create_surface(name, {width = 1, height = 1, peaceful_mode = true})
surface.always_day = true
surface.show_clouds = false
end
Shouldn't this be sufficient?
For purpose of helper surfaces, you can set the map size to 1x1. This is how I designed AAI-Signal-Transmission's helper surface.
That's the size I set on creating surfaces. But I need more space because I must place an entity for each player there, spaced 10 tiles apart from each other so the different entities won't overlap on camera. (I can't use the same entity for all players because each preview character will wear the same armor as the player it belongs to.) Yet it seems I can create entities anywhere on the surface, and I can also teleport player.character
to any position on this surface, but I can't move it beyond the limits set by surface.width
and surface.height
-- is that correct?
I hope this addresses your concerns!
Actually, I get some crashes:
On adding your mod to a game where my preview surfaces already existed:
Error while running event DivOresity::on_init()
__DivOresity__/control.lua:33: attempt to index field 'autoplace_controls' (a nil value)
stack traceback:
__DivOresity__/control.lua:33: in function 'enrich_surface'
__DivOresity__/control.lua:17: in function <__DivOresity__/control.lua:13>
You can fix that by adding a check for autoplace_controls
:
for resource_name, resource in pairs(game.entity_prototypes) do
if resource.type == "resource"
--and resource.resource_category == "basic-solid"
--and resource.autoplace_specification
and surface.map_gen_settings.autoplace_controls and -- ADDED LINE
and surface.map_gen_settings.autoplace_controls[resource_name]
and surface.map_gen_settings.autoplace_controls[resource_name].size > 0 then
You could even improve this by looping over a list of just the resources instead of all entities:
local resources = game.get_filtered_entity_prototypes({ {filter = "type", type = "resource"} })
for resource_name, resource in pairs(resources) do
if surface.map_gen_settings.autoplace_controls and
surface.map_gen_settings.autoplace_controls[resource_name] and
surface.map_gen_settings.autoplace_controls[resource_name].size > 0 then
I also get a crash when I start a new game:
Error while running event minime::on_init()
The mod DivOresity (1.2.0) caused a non-recoverable error.
Please report this error to the mod author.
Error while running event DivOresity::on_surface_created (ID 63)
__DivOresity__/control.lua:26: attempt to index local 'surface' (a nil value)
stack traceback:
__DivOresity__/control.lua:26: in function <__DivOresity__/control.lua:24>
stack traceback:
[C]: in function 'create_surface'
__minime__/control.lua:239: in function 'init'
__minime__/control.lua:328: in function <__minime__/control.lua:325>
You try to get the surface using
local surface = event.surface
This doesn't work because the events on_surface_created
, on_surface_imported
, and on_surface_deleted
pass on event.surface_index
instead of event.surface
, so you should use
local surface = event.surface or (event.surface_index and game.surfaces[event.surface_index])