What "can" be changed without re-compiling?

News and discussion of the PC port of Oolite.

Moderators: winston, another_commander

User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 5273
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: What "can" be changed without re-compiling?

Post by phkb »

Cholmondely wrote: Wed Aug 17, 2022 9:34 pm
What about all this?
That stuff is really good, but doesn't cover with the limitation I was pointing out. For example, at the moment, we can create a character in the "characters.plist" file, like this:

Code: Select all

{
	myPerson = {
		role = trader;
		name = "Captain Bob";
		script = "myPerson.js";
	};
}
That script file can have some code in it like this:

Code: Select all

// filename "myPerson.js"
this.unloadCharacter = function() {
	// ... Javascript code to do something ...
}
You could then give a ship the "myPerson" character in shipdata.plist

Code: Select all

{
	"myship" = {
		... various shipdata entries ...
		"pilot" = "myPerson";
	};
}
Now, if you were to destroy that ship, and the pilot ejects, and you scoop that escape pod, when you dock at a station and the rescued pilot is unloaded, the "unloadCharacter" function in the "myPerson.js" script file will be executed.

BUT! And this is the point I was making - there is no way to access that script file during play. It's not accessible in the same way other worldscripts are that are declared in the "world-scripts.plist" file. Also, you can't programmatically assign a script to a character during play. So, all characters and their scripts have to be predefined by an OXP before the game starts. This is what I meant when I said "You can't directly reference and/or assign a script to a character".

Hopefully that makes a bit more sense.
User avatar
Cholmondely
Archivist
Archivist
Posts: 6227
Joined: Tue Jul 07, 2020 11:00 am
Location: The Delightful Domains of His Most Britannic Majesty (industrial? agricultural? mainly anything?)
Contact:

Re: What "can" be changed without re-compiling?

Post by Cholmondely »

Can we replicate this in Oolite?

(Pioneer's Acropolis - Visiting ancient ruins in Pioneer)
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
Cholmondely
Archivist
Archivist
Posts: 6227
Joined: Tue Jul 07, 2020 11:00 am
Location: The Delightful Domains of His Most Britannic Majesty (industrial? agricultural? mainly anything?)
Contact:

Re: What "can" be changed without re-compiling?

Post by Cholmondely »

phkb wrote: Mon Aug 22, 2022 4:51 am
... BUT! And this is the point I was making - there is no way to access that script file during play. It's not accessible in the same way other worldscripts are that are declared in the "world-scripts.plist" file. Also, you can't programmatically assign a script to a character during play. So, all characters and their scripts have to be predefined by an OXP before the game starts. This is what I meant when I said "You can't directly reference and/or assign a script to a character".

Hopefully that makes a bit more sense.
Looking this over - presumably one could create a special escape pod with a script attached for the NPC and use that instead? And then carry that over to some sort of interaction inside a station and then carry that over to the dreaded NPC whizzing off in another ship?

[EliteWiki] Localhero OXP (Svengali)

Code: Select all

	"harkov_escape1" =
	{
		bounty = 0;
		cargo_type = "CARGO_SCRIPTED_ITEM";
		conditions =
		(
			"galaxy_number lessthan 5",
			"systemTechLevel_number greaterthan 7",
			"systemGovernment_number equal 5",
			"score_number greaterthan 50"
		);
		likely_cargo = 0;
		model = "escpod_redux.dat";
		name = "Harkov Member Escape Pod";
		roles = "harkov_pod1";
		scanClass =	"CLASS_CARGO";
		script = "harkov_pod1.js";
		subentities =
		(
			"*FLASHER* 0.0 4.42 -1.54 0.0 2 0.0 5.0",
			"*FLASHER* 3.83 -2.21 -1.54 0.0 2 0.0 5.0",
			"*FLASHER* -3.83 -2.21 -1.54 0.0 2 0.0 5.0"
		);
		thrust = 5;
	};
	"harkov_escape2" =
	{
		conditions =
		(
			"galaxy_number lessthan 5",
			"systemTechLevel_number greaterthan 7",
			"systemGovernment_number equal 5",
			"score_number greaterthan 50"
		);
		like_ship =	"harkov_escape1";
		name = "Harkov Leader Escape Pod";
		roles = "harkov_pod2";
		script = "harkov_pod2.js";
	};
	"harkov_escape3" =
	{
		ai_type = "harkovpodAI.plist";
		auto_ai = no;
		bounty = 0;
		conditions =
		(
			"galaxy_number lessthan 5",
			"systemTechLevel_number greaterthan 7",
			"systemGovernment_number equal 5",
			"score_number greaterthan 50"
		);
		like_ship =	"harkov_escape1";
		name = "General Harkov Escape Pod";
		roles = "harkov_pod3";
		script = "harkov_pod3.js";
	};
	"harkov_escape4" =
	{
		conditions =
			(
				"galaxy_number lessthan 5",
				"systemTechLevel_number greaterthan 7",
				"systemGovernment_number equal 5",
				"score_number greaterthan 50"
			);
		like_ship =	"harkov_escape1";
		name = "Committee Escape Pod";
		roles = "harkov_pod4";
		script = "harkov_pod4.js";
	};
	"harkov_escape5" =
	{
		conditions =
			(
				"galaxy_number lessthan 5",
				"systemTechLevel_number greaterthan 7",
				"systemGovernment_number equal 5",
				"score_number greaterthan 50"
			);
		like_ship =	"harkov_escape1";
		name = "Governor Escape Pod";
		roles = "harkov_pod5";
		script = "harkov_pod5.js";
	};
One of the escape pod scripts:

Code: Select all

this.name           = "harkov_pod4";
this.author         = "Svengali";
this.copyright      = "CC-by-nc-sa-3";
this.description    = "Localhero Part I - V1.05";
this.version        = "1.01";

this.shipWasScooped = function(scooper)
{
	if (scooper.isPlayer)
	{
		missionVariables.localhero_special = "RESCUED";
		missionVariables.localhero_goal -= 80;
		missionVariables.localhero_bonus += 200;
		player.commsMessage("Caution: Scooped escape pod runs out of oxygen!");
		delete this.shipWasScooped;
	}
}

this.shipDied = function()
{
	missionVariables.localhero_special = "FAILED";
	delete this.shipWasScooped;
	delete this.shipDied;
}
One of the escape pod AIs:

Code: Select all

{
	GLOBAL = {ENTER = ("setStateTo: HARKOVS_LAST_WILL1"); EXIT = (); UPDATE = (); };
	"HARKOVS_LAST_WILL1" = {
		ENTER = ();
		UPDATE = ("pauseAI: 10.0", "setStateTo: HARKOVS_LAST_WILL2");
		EXIT = ();
	};
	"HARKOVS_LAST_WILL2" = {
		ENTER = ("sendScriptMessage: harkovWill1");
		UPDATE = ("pauseAI: 10.0", "setStateTo: HARKOVS_LAST_WILL3");
		EXIT = ();
	};
	"HARKOVS_LAST_WILL3" = {
		ENTER = ("sendScriptMessage: harkovWill2");
		UPDATE = ("pauseAI: 10.0", "setStateTo: HARKOVS_LAST_WILL4");
		EXIT = ();
	};
	"HARKOVS_LAST_WILL4" = {
		ENTER = ("sendScriptMessage: harkovWill3");
		UPDATE = ("pauseAI: 10.0", "setStateTo: HARKOVS_LAST_WILL");
		EXIT = ();
	};
	"HARKOVS_LAST_WILL" = {
		ENTER = ("setDesiredRangeTo: 5000", becomeEnergyBlast);
		UPDATE = ();
		EXIT = ();
	};
}
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?
Post Reply