on_surface_created event
on_surface_created event
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.
I also update mods, some of them even work.
Recently I did a mod tutorial.
Re: on_surface_created event
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 !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.
Re: on_surface_created event
I've though of storing some surface-specific info into global tables indexed by surface. As in
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.
Code: Select all
global.stuff[nauvis]={detailed stuff}
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.
I also update mods, some of them even work.
Recently I did a mod tutorial.
Re: on_surface_created event
Can do this now from chunk generation event. It provides surface in the event handler directly.Adil wrote:I've though of storing some surface-specific info into global tables indexed by surface. As inCurrently 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.Code: Select all
global.stuff[nauvis]={detailed stuff}
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.
Re: on_surface_created event
It is still a needless waste of performance no matter how little you do in a function.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.
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.