[SOLVED] editor plugins and world_reload


photo

Recommended Posts

It would be nice to have some sort of hook in the editor plugins that detects when a new world is loaded... is this currently possible?

Link to post

Hi Danni, just a quick idea

 

/******************************************************************************\
*
* Plugin
*
\******************************************************************************/

string  plugin_world_name = "no_world";

/* this function should return plugin namespace name
*/
string getName() { return "Your plugin name"; }
/* plugin init
*/

void init() {
}

/* plugin shutdown
*/
void shutdown() {
}

/* plugin update, need_reload flag indicates that the editor resources should be updated
*/
void update(int need_reload) {

string world_name = engine.world.getName();

if( world_name != plugin_world_name )
{
   	// initial of new world loaded
   	.....
   	// actions on world_load
}

plugin_world_name = world_name;
...

}

Link to post

my solution was to add code to the world init function that checks whether the editor is loaded (this is only true on a world reload) and send a signal to the editor.

Link to post

Another workaround is to check the game time. If the game time value is small that means we have a new world loaded.

Link to post