Page 1 of 1

[Lua] help needed with ore generated on water/void

Posted: Mon Dec 17, 2018 4:03 pm
by Trblz
I am creating a scenario with a grid based world where the grids are separated by voids.

So far it works well except that my ores are also generated on top of the water and voids. I tried the get_tile entity to check for existing surfaces but it fails.

Code: Select all

if (not game.surfaces.get_tile(x,y).collides_with("water-tile")) then
	game.surfaces["nauvis"].create_entity({name=ore, amount=ore_amount, position={x,y}})
end
 
then i get error ID12: attempt to call field 'get_tile' (a nil value)

Re: [Lua] help needed with ore generated on water/void

Posted: Mon Dec 17, 2018 4:31 pm
by Bilka
Trblz wrote: Mon Dec 17, 2018 4:03 pm game.surfaces.get_tile(x,y)
You are trying to call get_tile() on a custom dictionary of surfaces. You have to call it on a specific surface instead. If you want to call it on nauvis for example, you use game.surfaces['nauvis'].get_tile(x,y)

Re: [Lua] help needed with ore generated on water/void

Posted: Mon Dec 17, 2018 6:21 pm
by Trblz
Thanks Bilka - that was the mistake

I am running this ore generation script as part of a scenario however the surface map is always the same.
can i trigger random surface generation w/o ores using (game.surfaces.map_gen_settings and regenerate_entity?

Re: [Lua] help needed with ore generated on water/void

Posted: Mon Dec 17, 2018 7:17 pm
by Bilka
If you have a scenario and don't want a pregenerated map, simply don't include blueprint.dat in the scenario.