Jump to content

[SOLVED] editor plugins and world_reload


photo

Recommended Posts

Posted

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?

Posted

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;
...

}

Posted

actually that will only work if the world actually changes, but not on a world refresh

Posted

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.

Posted

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

×
×
  • Create New...