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

Place to get help with not working mods / modding interface.
Post Reply
User avatar
Trblz
Long Handed Inserter
Long Handed Inserter
Posts: 63
Joined: Thu Sep 21, 2017 1:23 am
Contact:

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

Post 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)
My Mod list: Necormant co-author

Bilka
Factorio Staff
Factorio Staff
Posts: 3128
Joined: Sat Aug 13, 2016 9:20 am
Contact:

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

Post 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)
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

User avatar
Trblz
Long Handed Inserter
Long Handed Inserter
Posts: 63
Joined: Thu Sep 21, 2017 1:23 am
Contact:

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

Post 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?
My Mod list: Necormant co-author

Bilka
Factorio Staff
Factorio Staff
Posts: 3128
Joined: Sat Aug 13, 2016 9:20 am
Contact:

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

Post by Bilka »

If you have a scenario and don't want a pregenerated map, simply don't include blueprint.dat in the scenario.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

Post Reply

Return to “Modding help”