Scripters cove

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

User avatar
Cholmondely
Archivist
Archivist
Posts: 6375
Joined: Tue Jul 07, 2020 11:00 am
Location: The Delightful Domains of His Most Britannic Majesty (industrial? agricultural? mainly anything?)
Contact:

Re: Scripters cove

Post by Cholmondely »

Wildeblood wrote: Wed Apr 16, 2025 3:13 am
Here you go, working example: https://wiki.alioth.net/index.php/File: ... _Manor.oxz

I look forward to seeing an illustration of Cousin Digby's pile on Digebiti.
Cousin Digby's pile.jpg
More like a castle than a manse, sorry.

It's those Mountain Seoids, you see. They can do a lot of damage to a manse. Something more defensive has a better chance to protect those inside. As happened a century back - Duke Dorian and his entourage were then attacked by one in the castle and survived the experience. The castle survived too, just needing some pointing and a repaint of the inside of the drawing room.
Comments wanted:
Missing OXPs? What do you think is missing?
Lore: The economics of ship building How many built for Aronar?
Lore: The Space Traders Flight Training Manual: Cowell & MgRath Do you agree with Redspear?
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2856
Joined: Sat Jun 11, 2011 6:07 am
Location: Nova Hollandia
Contact:

Re: Scripters cove

Post by Wildeblood »

Cholmondely wrote: Sun May 25, 2025 8:32 pm
I look forward to seeing an illustration of Cousin Digby's pile on Digebiti.
Gimme bigga piccy. At least 1024 x 512.
"Must keep this response efficient to preserve remaining context."
User avatar
Redspear
---- E L I T E ----
---- E L I T E ----
Posts: 2890
Joined: Thu Jun 20, 2013 10:22 pm
Location: On the moon Thought, orbiting the planet Ignorance, looking through a telescope with the lens cap on

Re: Scripters cove

Post by Redspear »

It's a simple matter to prevent a player buying a commodity at a station (set market quantity to 0) but is there a simple way to prevent a player from selling a commodity at a station?

I'm trying to simulate a no demand situation without just lowering the market price significantly.
I want to not only discourage the player from selling but to actually prevent them from doing so without confiscation.
User avatar
cbr
---- E L I T E ----
---- E L I T E ----
Posts: 1540
Joined: Thu Aug 27, 2015 4:24 pm

Re: Scripters cove

Post by cbr »

Wildeblood wrote: Mon May 26, 2025 2:38 pm
Cholmondely wrote: Sun May 25, 2025 8:32 pm
I look forward to seeing an illustration of Cousin Digby's pile on Digebiti.
Gimme bigga piccy. At least 1024 x 512.
Image
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 5369
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Scripters cove

Post by phkb »

Redspear wrote: Fri Jun 20, 2025 7:33 pm
It's a simple matter to prevent a player buying a commodity at a station (set market quantity to 0) but is there a simple way to prevent a player from selling a commodity at a station?

I'm trying to simulate a no demand situation without just lowering the market price significantly.
I want to not only discourage the player from selling but to actually prevent them from doing so without confiscation.
I’ve always used the playerSoldCargo world event, and just reversed the effects of the passed parameters. If I remember I’ll post a code snippet doing this later this morning.
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2856
Joined: Sat Jun 11, 2011 6:07 am
Location: Nova Hollandia
Contact:

Re: Scripters cove

Post by Wildeblood »

Redspear wrote: Fri Jun 20, 2025 7:33 pm
It's a simple matter to prevent a player buying a commodity at a station (set market quantity to 0) but is there a simple way to prevent a player from selling a commodity at a station?

I'm trying to simulate a no demand situation without just lowering the market price significantly.
I want to not only discourage the player from selling but to actually prevent them from doing so without confiscation.
Set capacity to 0. And, see the market script in this, for my experiments:

https://wiki.alioth.net/index.php/File: ... difier.oxz
"Must keep this response efficient to preserve remaining context."
User avatar
Redspear
---- E L I T E ----
---- E L I T E ----
Posts: 2890
Joined: Thu Jun 20, 2013 10:22 pm
Location: On the moon Thought, orbiting the planet Ignorance, looking through a telescope with the lens cap on

Re: Scripters cove

Post by Redspear »

Wildeblood wrote: Sat Jun 21, 2025 12:50 pm
Set capacity to 0
That looks like what I was after (forgot to check plist options), thanks!

phkb wrote: Fri Jun 20, 2025 9:30 pm
I’ve always used the playerSoldCargo world event, and just reversed the effects of the passed parameters. If I remember I’ll post a code snippet doing this later this morning.
That would still be of interest if not inconvenient for you.
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 5369
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Scripters cove

Post by phkb »

Redspear wrote: Sat Jun 21, 2025 9:19 pm
That would still be of interest if not inconvenient for you.

Code: Select all

//-------------------------------------------------------------------------------------------------------------
// stop the player from selling cargo (in this case, slaves)
this.playerSoldCargo = function (commodity, units, price) {
    var p = player.ship;
    var stn = p.dockedStation;
    if (commodity === "slaves") {
        var refund = units;
        // take credits off player
        player.credits -= ((price / 10) * refund);
        // give commodity back to player
        p.manifest[commodity] += refund;
        // take commodity away from station
        stn.setMarketQuantity(commodity, stn.market[commodity].quantity - refund);
        // Market Observer interface - make sure this doesn't impact on it's data
        if (worldScripts.market_observer3) {
            this._sale = {
                commodity: commodity,
                units: units,
                price: price
            };
            this._mo_timer = new Timer(this, this.$reverseMOSale, 0.25, 0);
        }
    }
}

//-------------------------------------------------------------------------------------------------------------
this.$reverseMOSale = function $reverseMOSale() {
    var mo = worldScripts.market_observer3;
    mo.playerBoughtCargo(this._sale.commodity, this._sale.units, this._sale.price);
    this._sale = {};
}
User avatar
Redspear
---- E L I T E ----
---- E L I T E ----
Posts: 2890
Joined: Thu Jun 20, 2013 10:22 pm
Location: On the moon Thought, orbiting the planet Ignorance, looking through a telescope with the lens cap on

Re: Scripters cove

Post by Redspear »

phkb wrote: Sat Jun 21, 2025 10:29 pm
...
Thanks.
User avatar
Redspear
---- E L I T E ----
---- E L I T E ----
Posts: 2890
Joined: Thu Jun 20, 2013 10:22 pm
Location: On the moon Thought, orbiting the planet Ignorance, looking through a telescope with the lens cap on

Re: Scripters cove

Post by Redspear »

Probably an easy one for somebody...

I wish to restrict a laser to a particular mounting (e.g. fore).

I further wish to test if a mounting is empty and (once a certain item is installed on the player ship) deny access to it.

Please, thanks, you superior coders you.
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2856
Joined: Sat Jun 11, 2011 6:07 am
Location: Nova Hollandia
Contact:

Re: Scripters cove

Post by Wildeblood »

Redspear wrote: Sun Jul 20, 2025 9:33 am
I wish to restrict a laser to a particular mounting (e.g. fore).

I further wish to test if a mounting is empty and (once a certain item is installed on the player ship) deny access to it.
*BUMP* Redspear's question remains of interest. And now, mine:

Apart from the ghost of Svengali leaving a terse note in Latest.log, what actually happens if one creates a new global object in Oolite's javascript environment? Will it explode? Run slower? Report one to the FBI?

Does the newly-minted object become addressable and modifiable, well, globally? Or is there like um, you know, a whole procedure to follow, lest it just hang around doing nothing but wasting space?
"Must keep this response efficient to preserve remaining context."
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 5369
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Scripters cove

Post by phkb »

I think the only way to restrict where a laser can be mounted is to capture the purchase event to an item that is not actually a laser, show a custom mission screen with the limited choices on offer, and then do the install of the actual laser item at that point.

There will be a lot of breaking points, though. Laser Arrangement allows you to move a laser to any mount. Equipment storage allows you to store lasers and then put them back in any position. There’s probably a couple of others as well. Just so you know.

Checking for an empty laser mount should be checking for EQ_WEAPON_NONE in the equipment key for the position (ie. player.ship.aftWeapon.equipmentKey)
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 5369
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Scripters cove

Post by phkb »

Wildeblood wrote: Sat Aug 09, 2025 10:28 am
what actually happens if one creates a new global object in Oolite's javascript environment? Will it explode? Run slower? Report one to the FBI?

Does the newly-minted object become addressable and modifiable, well, globally? Or is there like um, you know, a whole procedure to follow, lest it just hang around doing nothing but wasting space?
I think it's (a) the potential for confusion if two scripts attempt to create the same global object, or of core code changes adding global objects and breaking things; and (b) it's just bad programming practice to put things into global that don't need to be there.
User avatar
Redspear
---- E L I T E ----
---- E L I T E ----
Posts: 2890
Joined: Thu Jun 20, 2013 10:22 pm
Location: On the moon Thought, orbiting the planet Ignorance, looking through a telescope with the lens cap on

Re: Scripters cove

Post by Redspear »

Wildeblood wrote: Sat Aug 09, 2025 10:28 am
*BUMP* Redspear's question remains of interest. And now, mine:
Thanks.
phkb wrote: Sat Aug 09, 2025 11:30 am
I think the only way to restrict where a laser can be mounted is to capture the purchase event to an item that is not actually a laser, show a custom mission screen with the limited choices on offer, and then do the install of the actual laser item at that point.
Thanks phkb. I was afraid it might be somewhat clunky (esp given other oxp involvement as you mention). The above does make sense however and could work well in isolation. Hmm...
User avatar
Lone_Wolf
---- E L I T E ----
---- E L I T E ----
Posts: 613
Joined: Wed Aug 08, 2007 10:59 pm
Location: Netherlands

Re: Scripters cove

Post by Lone_Wolf »

In ShieldCycler 2.1 I found this (by dybal) :

Code: Select all

this.playerBoughtNewShip = this.playerReplacedShip = function _sc_playerReplacedShip(ship) {// player ship only
    var wsc = worldScripts["Shield Cycler"];

    this.ship = player.ship;
    // sell shieldcycler equipment if still present and reset settings 
    if (this.$sc_settings.version !== 0) {
        log(this.name, "Player's got a new ship, removing Shield Cycler equipments");
        if (this.$sc_settings.manual_version !== 0) 
            wsc._sc_remove_manual();
        wsc._sc_remove_shield_cycler();
        wsc._sc_update_status();
    }
}
The equivalent code in Sc 1.x (by me ) uses the full value instead of a var .

Is there an execution advantage for using a var to call worldscripts or is this cosmetic/style related ?
OS : Arch Linux 64-bit - rolling release

From: The Netherlands, Europe

OXPs : My user page
(needs updating)

Retired, occasionally active
Post Reply