Maintenance upon demmand

An area for discussing new ideas and additions to Oolite.

Moderators: winston, another_commander

User avatar
phkb
Commodore
Commodore
Posts: 2433
Joined: Tue Jan 21, 2014 10:37 pm
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...

Re: Maintenance upon demmand

Post by phkb » Thu Jul 18, 2019 10:24 am

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!

User avatar
Nite Owl
Dangerous
Dangerous
Posts: 110
Joined: Sat Jan 20, 2018 4:08 pm
Location: In The Dark

Re: Maintenance upon demmand

Post by Nite Owl » Thu Jul 18, 2019 2:51 pm

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.
Humor is the second most subjective thing on the planet

Brevity is the soul of wit and vulgarity is wit's downfall

Good Night and Good Luck - Read You Soon

Post Reply