Scripters cove

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

Moderators: winston, another_commander

User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2575
Joined: Sat Jun 11, 2011 6:07 am
Location: Nova Hollandia
Contact:

Re: Scripters cove

Post by Wildeblood »

Phasted wrote: Fri Jan 31, 2025 7:28 am
Phasted wrote: Tue Jan 21, 2025 8:27 pm
I'd like to avoid tossing any garbage into the global space if it's at all possible...
I'm reluctant to do it, but here's what I'm thinking:

Code: Select all

// ...in the worldScript (outside of any function...)
if(!OXP){var OXP = {};} //  creates an "OXP" object in the global space 
OXP.JEM = {}; // A "JEM" object as a property of "OXP", claiming a chunk of the OXP object for myself (JEM -- my initials).
OXP.JEM.RLE = {};  // An "RLE" object to provide a home for everything "Real-life Economics"-related...
// ... then in the market script (or whatever other script to which I need a reference)
OXP.JEM.RLE.someCleverlyNamedProperty = this;
I can then refer to that script from any other script... as can anyone else from any script in any OXP...

Anybody else who wants a piece of the action can attach their own JEM-equivalent object to "OXP" and have at it!

One little object in the global space isn't really such a big deal, right? :roll:
But that depends on doing stuff from the market script; you asked if you could access market scripts from world scripts, not whether you could access world scripts from market scripts.

You don't need a global object for that, just use a normal world script:-

Code: Select all

worldScripts.marketDefs.RLE.CleverlyNamedProperty = this;
"There are large, white swans, and there are small, black swans," he explained, "But there are no medium-sized swans, and there are no grey swans. The non-existence of grey swans mitigates against belief in Mr Darwin's theory."
User avatar
Phasted
Competent
Competent
Posts: 54
Joined: Wed Jun 09, 2010 3:56 pm

Re: Scripters cove

Post by Phasted »

Wildeblood wrote: Fri Jan 31, 2025 10:11 am
Phasted wrote: Fri Jan 31, 2025 7:28 am
Phasted wrote: Tue Jan 21, 2025 8:27 pm
I'd like to avoid tossing any garbage into the global space if it's at all possible...

You don't need a global object for that, just use a normal world script:-

Code: Select all

worldScripts.marketDefs.RLE.CleverlyNamedProperty = this;
I can put that line in the market script and then address that market script as:

Code: Select all

worldScripts.marketDefs.RLE.CleverlyNamedProperty
I didn't know worldScripts could be used that way... I thought the only properties of worldScripts were the this.name properties of the loaded world scripts...
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4888
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: Wed Jan 29, 2025 7:05 pm
Phasted has asked if something can be done, and I've answered honestly that I believe not, but would be pleased if I were wrong.
You're correct.
Phasted wrote: Tue Jan 21, 2025 8:27 pm
I'm wracking my brains and coming up empty...
In case you end up trying to re-invent the wheel: Market Script Interface
User avatar
Redspear
---- E L I T E ----
---- E L I T E ----
Posts: 2731
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 »

I'd like to mimic the energy bomb behaviour of the zx spectrum version of elite.

In that incarnation, the Thargoids were (almost) immune to the device whereas any Thargons (or other ships for that matter) would be destroyed.

So I'm looking to extend the same immunity that the player has (upon launching the device) to any Thargoids (but not their drones) within range.

Anyone know a simple method to achieve same?
I can't access the oxp right now to poke around but from memory it wasn't something I knew how to do.
Post Reply