on_surface_created event

User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

on_surface_created event

Post by Adil »

We have event which is raised when force is created by script,but there seems to be no event which alerts mods about creation of new surface.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.
User avatar
StanFear
Fast Inserter
Fast Inserter
Posts: 236
Joined: Sun Dec 15, 2013 2:49 pm
Contact:

Re: on_surface_created event

Post by StanFear »

Adil wrote:We have event which is raised when force is created by script,but there seems to be no event which alerts mods about creation of new surface.
why would you need it ? a surface can't be renamed, and when the surface is created, no chunks are generated yet ... You'd be better off looking at the on_chunk_generated event if you want to do stuff to the surface !
User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: on_surface_created event

Post by Adil »

I've though of storing some surface-specific info into global tables indexed by surface. As in

Code: Select all

global.stuff[nauvis]={detailed stuff}
Currently my mods do okay by checking whether an index has been initialized in the table but I suppose there might be some situations, when you'd want to perform initialization beforehand and maybe even start performing calculations from there on.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.
orzelek
Smart Inserter
Smart Inserter
Posts: 3924
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: on_surface_created event

Post by orzelek »

Adil wrote:I've though of storing some surface-specific info into global tables indexed by surface. As in

Code: Select all

global.stuff[nauvis]={detailed stuff}
Currently my mods do okay by checking whether an index has been initialized in the table but I suppose there might be some situations, when you'd want to perform initialization beforehand and maybe even start performing calculations from there on.
Can do this now from chunk generation event. It provides surface in the event handler directly.
Unless you are planning some extensive precalculations then you'd need to use ticks to do the job in small parts as not to lag the game.
credomane
Filter Inserter
Filter Inserter
Posts: 311
Joined: Tue Apr 12, 2016 6:21 pm
Contact:

Re: on_surface_created event

Post by credomane »

orzelek wrote: Can do this now from chunk generation event. It provides surface in the event handler directly.
Unless you are planning some extensive precalculations then you'd need to use ticks to do the job in small parts as not to lag the game.
It is still a needless waste of performance no matter how little you do in a function.
Having to check every single chunk generation event for what surface it occurred on, then check if that surface is already in your list of known surfaces. All for the low chance the event occurs on a new surface to finally add that surface to the known list + some config init for the new surface. That is very inefficient. Whenever the devs starting adding their own new surfaces to the base game and/or a multi-surface mod(s) come about a on_surface_created event is going to be a necessity fast.

Why have a on_player_created event when you could just scan game.players for new players on every tick? Same basic principal.
Post Reply

Return to “Implemented mod requests”