Kaks you are right but I thought that both ways are identical.Kaks wrote:I think he meansCode: Select all
delete this.startUp;
Here is the version using delete instead:
Code: Select all
this.name = "Oxp_A";
this.author = "Author";
this.copyright = "license";
this.description = "Some Description";
this.version = "1.0 alpha 1";
this.startUp = function()
{
delete this.startUp; // Must be done straight away to prevent loops. It doesn't stop this function from working.
// For handling oxps that are written using this template:
if (worldScripts.Oxp_B.startUp) worldScripts.Oxp_B.startUp(); // Calls Oxp_B.startUp as it is required to load before your Oxp_A.
// Repeat above for each OXP that this OXP depends on.
// For handling old oxps that are NOT written using this template:
if (worldScripts.Oxp_Old.startUp)
{
worldScripts.Oxp_Old.startUp(); // Calls Oxp_Old.startUp as it is required to load before your Oxp_A.
delete worldScripts.Oxp_Old.startUp; // You do this as Oxp_Old can't.
}
// Repeat above for each old OXP that this OXP depends on.
// Test for existence of an OXP that isn't required but effects the way this OXP works.
if (worldScripts["Oxp_X"])
{
this.Oxp_X_Exists = true;
}
else
{
this.Oxp_X_Exists = false;
}
// Repeat above for other similar OXP checks.
// Do other stuff here as required
log(this.name + " " + this.version +" loaded."); // This goes last so the load messages appear the sensible order.
}
// Do other stuff here as required
That's what I thought.Kaks wrote:On restart / reload all scripts are reloaded from scratch, so any deleted this.startUp function will be back there, ready to be deleted again.