Page 1 of 1

Conditional Stuff

Posted: Thu Sep 21, 2023 7:58 am
by Killer Wolf
is it possible to use the "allowOfferShip" function to make a ship only available for purchase at one station/system?

Is it possible to control the appearance of subents? eg, if i had a station w/ a couple of sub ent ships docked outside, could a script/whatever randomly make one or more of them disappear so the station always looked different?

TIA

Re: Conditional Stuff

Posted: Thu Sep 21, 2023 10:03 am
by Alnivel
Killer Wolf wrote: Thu Sep 21, 2023 7:58 am
is it possible to use the "allowOfferShip" function to make a ship only available for purchase at one station/system?
At one system - yes:

Code: Select all

this.allowOfferShip = function(shipkey) {
    if(galaxyNumber === 0 && system.ID === 7) // Lave
        return true;
    else
        return false;
}
But for a specific station, you probably need to manually add a ship to the shipyard via addShipToShipyard at station's shipSpawned event.

Killer Wolf wrote: Thu Sep 21, 2023 7:58 am
Is it possible to control the appearance of subents? eg, if i had a station w/ a couple of sub ent ships docked outside, could a script/whatever randomly make one or more of them disappear so the station always looked different?

TIA
You can let them all appear and then remove the ones you don't need. But adding back removed subentities is quite troublesome and in some cases it can be easier instead of removing to hide a subentity inside the main entity if it is big enough.
Here is how to remove some subentities on the station's spawn:

Code: Select all

this.shipSpawned = function() {
    var subEntities = this.ship.subEntities;
    var i = subEntities.length;
    while(i--) {
        if(Math.random() < 0.1) // 10% chance each subentity to be removed
            subEntities[i].remove();
    }
}

Re: Conditional Stuff

Posted: Thu Sep 21, 2023 12:14 pm
by phkb
Alnivel wrote: Thu Sep 21, 2023 10:03 am
But adding back removed subentities is quite troublesome
You can do it, but you have to add all of them back at once, and then go through the list again and remove the ones you don't want.

To restore all subentities use:

Code: Select all

    mystation.restoreSubEntities();

Re: Conditional Stuff

Posted: Thu Sep 21, 2023 1:27 pm
by Killer Wolf
Much obliged, i'll check those out. i don't really need to add things back, i was thinking of having some subent ships/whatever hanging about in random order just to add colour - you might see one thing, or several, or none if a random scripty thing can zap them. i'll try a bit play wehn i've finished the models.

Re: Conditional Stuff

Posted: Thu Sep 21, 2023 1:53 pm
by cbr
Could/can you just 'add' ships with somekind of nullai?

Calculating the rotating position will be perhaps a bit difficult but Thargoid's yah-board position was calculated from the towing ship...

Re: Conditional Stuff

Posted: Thu Sep 21, 2023 8:38 pm
by Killer Wolf
Not sure i could do it accurately. The only spawn script i have is the one that sticks a station some specified distance along a line from witchpoint-sun etc etc. Rotation isn't a problem but accuracy is. Would be far easier to define the items as part of the model and either spawn or spawn-kill them.