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: 2628
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: 4962
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: 2762
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.
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2628
Joined: Sat Jun 11, 2011 6:07 am
Location: Nova Hollandia
Contact:

Re: Scripters cove

Post by Wildeblood »

Wildeblood wrote: Mon Aug 05, 2024 7:24 pm
I'm still having fun with screen backgrounds, and my next question is, can I switch off the rotating planet model on the F7 screen?
phkb wrote: Mon Aug 19, 2024 12:06 am
Not easily. I experimented with forcing the system to be a nova system (just temporarily), which would then allow you to manipulate the "system_data_nova" screen backgrounds id, but that was a bust. The nova settings for a system are read-only...
Wildeblood wrote: Mon Aug 19, 2024 7:58 am
Methinks, you do like to do things the hard way. If there's no "official" way to switch off the planet model, I would have tried experimenting with the planet's texture, attempting to make it transparent, or the planet's radius, trying to make it imperceptibly small, before I thought to mess about with the nova settings. Have you ever tried those approaches?
So, anyway... it turns out that setting radius: null completely suppresses the planet's image on F7, and doesn't leave any rude messages in Latest.log.
"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
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4962
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Scripters cove

Post by phkb »

Hey, that's good to know. And easier than this method:
Image
(which I can't reproduce anyway, but you know, something interesting I saw on the way to the station one time).
User avatar
Cholmondely
Archivist
Archivist
Posts: 5755
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: Sat Apr 12, 2025 2:02 am
So, anyway... it turns out that setting radius: null completely suppresses the planet's image on F7, and doesn't leave any rude messages in Latest.log.
Sorry, this is in the Planetinfo.plist?
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: 2628
Joined: Sat Jun 11, 2011 6:07 am
Location: Nova Hollandia
Contact:

Re: Scripters cove

Post by Wildeblood »

Cholmondely wrote: Mon Apr 14, 2025 10:18 pm
Wildeblood wrote: Sat Apr 12, 2025 2:02 am
So, anyway... it turns out that setting radius: null completely suppresses the planet's image on F7, and doesn't leave any rude messages in Latest.log.
Sorry, this is in the Planetinfo.plist?
No, from javascript. When one wants to supress the planet model on F7, to show an image of Wildeblood manor instead. Definitely don't try doing it from planetinfo.plist.

The transparent effect pictured above is likely from a mis-named texture file, and would have left an irate message in Latest.log.
"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
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4962
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Scripters cove

Post by phkb »

Actually there was nothing in the log file. When I launched from the station, the planet was visible. As I got closer, however, it just vanished.
I suspect Thargoids stole it.

Or possibly I was running out of memory.
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2628
Joined: Sat Jun 11, 2011 6:07 am
Location: Nova Hollandia
Contact:

Re: Scripters cove

Post by Wildeblood »

Wildeblood wrote: Sat Apr 12, 2025 2:02 am
So, anyway... it turns out that setting radius: null completely suppresses the planet's image on F7, and doesn't leave any rude messages in Latest.log.
And... I cannot reproduce this today. I swear, I did it several times yesterday to confirm what I was seeing, before I posted that message. But today, nah-uh. :shock: :!: :?: :?

Addendum: I think I know what's happening. BRB.

Added addendum: It does work. I have an error elsewhere in my scripts, they are immediately undoing the setting again. :?: :? :oops:

P.P.P.S. Turns out it only works from the console, or from a save-file, and was some kind of weirdness with the null evaluating to zero somewhere in the process. It does not work from a script. :cry:

P.P.P.P.S. Good news! My first instinct, that I intimated here months ago, was right! To suppress the planet image, just set its radius to zero. Then later use null to unset the zero and get back the normal image. :mrgreen: :lol:
"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
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2628
Joined: Sat Jun 11, 2011 6:07 am
Location: Nova Hollandia
Contact:

Re: Scripters cove

Post by Wildeblood »

Cholmondely wrote: Mon Apr 14, 2025 10:18 pm
Sorry, this is in the Planetinfo.plist?
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.
"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
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2628
Joined: Sat Jun 11, 2011 6:07 am
Location: Nova Hollandia
Contact:

Re: Scripters cove

Post by Wildeblood »

I'm searching through previous discussions of planetinfo and I came across this query, so better late than never, I'll chip in another two cents.
Redspear wrote: Mon Dec 05, 2022 3:54 pm

Code: Select all

if (System.infoForSystem(galaxyNumber, player.ship.targetSystem).ID < 86) {
        ...first code thing
	}
	else {
		if (System.infoForSystem(galaxyNumber, player.ship.targetSystem).ID < 171) {	
		...second
		}
		else {	
			...third
			}
		}		

Another cry for help...

Only the third of these options is ever firing.

Lave, for example, is ID #7 and so should trigger the first but it triggers the third instead :?
It works if I swap ID for economy for example (with different numbers of course).

That it triggers at all suggest that my use of '.ID' is ok but why no discrimination upon calling the value (of ID)?

Any advice please?
Alnivel gave this reply, which correctly explains the problem, but not the solution:
Alnivel wrote: Mon Dec 05, 2022 4:38 pm
System.infoForSystem returns a dictionary from planetinfo.plist, not a System object. The dictionary does not have an ID property, so the result is undefined. Is undefined lesser than 86? JS thinks not. Is undefined lesser than 171? Same, so the third branch is being executed.
He then gave the practical solution to the problem Redspear was having, which is this:
Alnivel wrote: Mon Dec 05, 2022 4:38 pm

Why are you even trying to get an ID through the system information if you already have one? You can just use it like this:

Code: Select all

if (player.ship.targetSystem < 86) {
        ...first code thing
}
else {
	if (player.ship.targetSystem < 171) {	
		...second
	}
	else {	
		...third
	}
}
But he didn't actually answer Redspear's question, of why System.infoForSystem(galaxyNumber, player.ship.targetSystem).ID was undefined. The answer is, the property sought is actually found here:

System.infoForSystem(galaxyNumber, player.ship.targetSystem).systemID
"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
Redspear
---- E L I T E ----
---- E L I T E ----
Posts: 2762
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: Thu Apr 17, 2025 11:40 pm
the property sought is actually found here:

System.infoForSystem(galaxyNumber, player.ship.targetSystem).systemID
Thanks Wildeblood.

I might be updating that oxp soon, so definitely better late than never.
Post Reply