Hi fellow modders,
I just came back to factorio and witnessed the changes in 0.12, create_entity now belongs to LuaSurface instead of LuaGame
The thing is I usually created entities at map generation near the player spawn with the event on_init and game.createentity
But now surface requires another entity to create one, eg: game.player.surface.create_entity{}
But on the event on_init, the player is not yet created, resulting in an error.
Is there a more appropriate way to call surface and create_entity without the help of the player ?
or is there another event called after the player initial spawn ?
(or should I monitor the how many times players have spawned and only call this on number one ?)
Thanks for the answers.
Surface and creating entities
-
- Burner Inserter
- Posts: 6
- Joined: Thu Apr 30, 2015 10:55 am
- Contact:
Re: Surface and creating entities
You can call a surface by its name
Code: Select all
game.surfaces.nauvis.create_entity
game.surfaces["nauvis"].create_entity
-
- Burner Inserter
- Posts: 6
- Joined: Thu Apr 30, 2015 10:55 am
- Contact:
Re: Surface and creating entities
Thanks a lot mate,
It is very unfortunate that the factorio Lua Wiki is down, I woudn't bother you with silly questions
It is very unfortunate that the factorio Lua Wiki is down, I woudn't bother you with silly questions