Page 2 of 2

Re: Maintenance upon demmand

Posted: Thu Jul 18, 2019 10:24 am
by phkb
It seemed appropriate to include the code in the actual OXP, so here it is, v0.3, with maintenance emails: MaintenanceTuneUp.oxz.

For the really keen, here's what I did:
First, the startupComplete event, I added this code:

Code: Select all

    if (worldScripts.GalCopAdminServices) {
        var ga = worldScripts.GalCopAdminServices;
        ga._purchase_ignore_equip.push("EQ_MAINTENANCE_TUNEUP"); // don't sent a normal purchase email for this one
    }
Essentially, this tells the GalCop Admin Services worldscript to ignore any purchase of the tune up equipment item. That's so we only get one email, not two.

Next, I added the following event handler

Code: Select all

this.guiScreenChanged = function(to, from) {
    if (to === "GUI_SCREEN_EQUIP_SHIP") {
        this._cost = player.ship.renovationCost;
    }
}
This grabs a copy of the players current renovation cost, so we can apply it to the email if required.

Finally, in the "playerBoughtEquipment" routine, I added this code:

Code: Select all

        if (worldScripts.GalCopAdminServices) {
            var ga = worldScripts.GalCopAdminServices;
            ga._maintCost = this._cost / 10;
            ga.$setupRepNames();
            ga.$sendMaintenanceEmail();
        }
All this does is applies the cost value we recorded earlier to GalCop Admin Servers, forces the rep names to be defined, and then sends the maintenance email.

Hope that makes sense!

Re: Maintenance upon demmand

Posted: Thu Jul 18, 2019 2:51 pm
by Nite Owl
Geez - No wonder it would not work for me, left out almost every step. Thank you again for both the update and the scripting lesson, much appreciated.