Join us at the Oolite Anniversary Party -- London, 7th July 2024, 1pm
More details in this thread.

Split: Deployable subentities

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

Moderators: winston, another_commander

User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Scripters cove

Post by cim »

dertien wrote:

Code: Select all

this.shipExitedWormhole = function()
{
    this.switchFlashersOff();
}
This event isn't applied to the player ship. "shipWillExitWitchspace" will work for the player.
dertien wrote:

Code: Select all

this.playerWillEnterWitchspace = function()
{
      this.switchFlashersOff();
}
playerWillEnterWitchspace is sent to the other ships remaining behind in the old system when the player jumps. It'll work, but you won't see it working. "shipWillEnterWitchspace" should work.
dertien
---- E L I T E ----
---- E L I T E ----
Posts: 471
Joined: Sun Jan 23, 2011 9:27 pm
Location: Belgium, Monarchy, Feudal, Overtaxed system

Re: Scripters cove

Post by dertien »

Thank you Cim that did it.

Following up on what Neelix said and using code I found from Commander Mc Lane's oxp here's what I was able to put together:

Selecting station and then the buoy for example does not retract the gear...

Code: Select all

this.name      = "HPC Cobra Mk3 ship scripts"; 
this.author    = "Cim, Dertien"; 
this.copyright = "Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0) http://creativecommons.org/licenses/by-nc-sa/3.0/"; 
this.version   = "1.00";

// Cim: So, what you can do is search through the subentities list until you find the one you want.

this._findSubEntity = function(key)
					{
					for (var i = this.ship.subEntities.length - 1 ; i >=0 ; --i)
						{
						if (this.ship.subEntities[i].dataKey == key)
							{
							return this.ship.subEntities[i];
							}
						}
						return null; // couldn't find it.
					}
					
//	reusable function that retracts the gear			
					
this.retractGear = function()

{
   var actuatorsR = this._findSubEntity("HPC_actuatorR"); 
               if (actuatorsR)
               {
                  actuatorsR.position = [0, 6.155206, 2.648078];
               }
	var actuatorsF = this._findSubEntity("HPC_actuatorF");
               if (actuatorsF)
               {
                  actuatorsF.position = [0, 3.80, -21.3];
               }
   var reargearextendPRT = this._findSubEntity("HPC_reargearPRT");
                  if (reargearextendPRT)
               {
               reargearextendPRT.position = [-17.392771, -8.961073, 2.796213];
			   reargearextendPRT.orientation = [0.9953, 0.0908, 0, 0];
               }
   var reargearextendSTB = this._findSubEntity("HPC_reargearSTB");
                  if (reargearextendSTB)
               {
               reargearextendSTB.position = [17.552752, -8.847222, 3.028129];
			   reargearextendPRT.orientation = [-0.9953, -0.0908, 0, 0];
               }
	var frontgearextendPRT = this._findSubEntity("HPC_frontgearPRT");
                  if (frontgearextendPRT)
               {
               frontgearextendPRT.position = [-13.038872, -5.954015, 25.049587];
			   reargearextendPRT.orientation = [0, 0, 0.9959, -0.0905];
               }
	var frontgearextendSTB = this._findSubEntity("HPC_frontgearSTB");
                  if (frontgearextendSTB)
               {
               frontgearextendSTB.position = [13.038872, -5.954015, 25.049587];
			   reargearextendPRT.orientation = [0.9959, 0.0905, 0, 0];
               }
	   
}

//	reusable function that extends the gear

this.extendGear = function()
{

		var actuatorsR = this._findSubEntity("HPC_actuatorR"); 
               if (actuatorsR)
               {
                  actuatorsR.position = [0,0,0];
               }
		var actuatorsF = this._findSubEntity("HPC_actuatorF"); 
               if (actuatorsF)
               {
                  actuatorsF.position = [0,0,0];
               }
		var reargearextendPRT = this._findSubEntity("HPC_reargearPRT");
                  if (reargearextendPRT)
               {
               reargearextendPRT.position = [-17.351349,-17.408951,-3.749173];
               }
		var reargearextendSTB = this._findSubEntity("HPC_reargearSTB");
                  if (reargearextendSTB)
               {
               reargearextendSTB.position = [17.435233,-17.338642,-3.50929];
               }
		var frontgearextendPRT = this._findSubEntity("HPC_frontgearPRT");
                  if (frontgearextendPRT)
               {
               frontgearextendPRT.position = [-12.765342,-11.194131,27.818142];
               }
		var frontgearextendSTB = this._findSubEntity("HPC_frontgearSTB");
                  if (frontgearextendSTB)
               {
               frontgearextendSTB.position = [12.765342,-11.194131,27.818142];
               }
}					


this.npcGearChecker = function()
{
	if (this.ship.dockingInstructions && this.ship !== player.ship)
		{
			this.ship.commsMessage("NPC GEAR DOWN");
			this.ship.commsMessage("NPC DOCKING NOW");
			this.extendGear();
			this.npcLandingChecker = new Timer(this, this.npcGearChecker,1, 10);
			return;
		}
}

// functions to switch the navlights on and off

this.switchFlashersOn = function()
{
	this.ship.lightsActive = true; // turns flashers on
}

this.switchFlashersOff = function()
{
	this.ship.lightsActive = false; // turns flashers off
}


this.noDockingComputer = function()
{
    
	if (this.ship == player.ship && this.ship.target && this.ship.target.isStation && player.ship.position.distanceTo(player.ship.target) < 11000)
    {
        player.consoleMessage("TEST: SUCCESS TARGET VALID");
        player.consoleMessage("TEST: SUCCESS GEAR DOWN");
		this.extendGear();
		this.dockingTargetChecker.stop();
        return;
    }
	if (this.ship == player.ship && this.ship.target && this.ship.target.isStation && player.ship.position.distanceTo(player.ship.target) > 11000)
    {
        player.consoleMessage("TEST: PROX WNG");
        player.consoleMessage("TEST: GEAR UP");
		this.retractGear();
		this.dockingTargetChecker.start();
        return;
    }
	
    if(!player.ship.target || player.ship.target !== this.ship.target.isStation)
    {
        player.consoleMessage("TEST: INVALID TGT");
        player.consoleMessage("TEST: GEAR UP");
		this.retractGear();
		this.dockingTargetChecker.start();
        return;
    }
	
	/*
    player.consoleMessage("Landing Gear up.");
    this.retractGear();
	*/
}


this.shipEnteredStationAegis = function(station)
{
   this.switchFlashersOn();
}
this.shipExitedStationAegis = function(station)
{
	this.switchFlashersOff();
}

this.shipDockedWithStation = function(station)
{
		this.switchFlashersOn();
		this.extendGear();
		this.dockingTargetChecker.stop();
		delete this.dockingTargetChecker;
		this.npcLandingChecker.stop();
		delete this.npcLandingChecker;
}	

// if the ship launches, show gear deployed and automatically retract after 10 seconds

this.shipLaunchedFromStation = function(station)
{
	this.extendGear();
	this.tenSecTimer = new Timer(this, this.retractGear,10);
	this.ship.commsMessage("GEAR UP in 10 Sec");
	this.switchFlashersOn();
	this.dockingTargetChecker = new Timer(this, this.noDockingComputer,11, 2);
	this.npcLandingChecker = new Timer(this, this.npcGearChecker,1, 10);
}

// if player hits C key with docking computers active gear drops

this.playerStartedAutoPilot = function()

{
	this.ship.commsMessage("Autopilot ON");
	this.ship.commsMessage("GEAR DOWN & LOCKED");
	this.switchFlashersOn();
	this.retractGear();
	this.extendGear();
	this.dockingTargetChecker.stop();
	delete this.dockingCheckTimer;   
}

// if player cancels docking computers gear retracts

this.playerCancelledAutoPilot = function() 
{
	this.ship.commsMessage("Autopilot OFF");
	this.ship.commsMessage("GEAR UP");
	this.retractGear();
	this.dockingTargetChecker = new Timer(this, this.noDockingComputer,1, 2);
}

// same as shipLaunchedFromStation function

this.shipLeavingPlanetSurface = function(planet)
{
    this.extendGear(); 
	this.tenSecTimer = new Timer(this, this.retractGear,10);
	this.dockingTargetChecker = new Timer(this, this.noDockingComputer,11, 2);
	this.ship.commsMessage("GEAR UP 10 Seconds");
}

// ship drops gear before planetary landing

this.shipApproachingPlanetSurface = function(planet)
{
	 this.extendGear();
	 this.ship.commsMessage("GEAR DOWN & LOCKED");
	 this.dockingTargetChecker.stop();
	 delete this.dockingCheckTimer;
}

this.shipWillExitWitchspace = function()
{
    this.switchFlashersOff();
	this.dockingTargetChecker = new Timer(this, this.noDockingComputer,1, 2);
}

this.shipWillEnterWitchspace = function()
{
    this.switchFlashersOff();
	this.dockingCheckTimer.stop();
    delete this.dockingCheckTimer;
}

this.stationWithdrewDockingClearance = function()
{
	this.retractGear();
	this.dockingCheckTimer.start();
}

this.shipWillLaunchFromStation = function(station)
{
	  this.extendGear();
}

Alpha Backer of Elite Dangerous
With 250 GBP :D
Zireael
---- E L I T E ----
---- E L I T E ----
Posts: 1396
Joined: Tue Nov 09, 2010 1:44 pm

Re: Scripters cove

Post by Zireael »

if(!player.ship.target || player.ship.target !== this.ship.target.isStation)
My gut tells me this line is bad. IIRC isStation is a boolean (true/false) and not a string, and player.ship.target returns a string...
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Scripters cove

Post by cim »

Zireael wrote:
and player.ship.target returns a string...
A ship, rather than a string, or null if there is no target selected. (If you try to log player.ship.target, you'll get the string representation of it, but player.ship.target is not itself a string)

Code: Select all

if (!player.ship.target || !player.ship.target.isStation)
is the correct test.
Zireael
---- E L I T E ----
---- E L I T E ----
Posts: 1396
Joined: Tue Nov 09, 2010 1:44 pm

Re: Scripters cove

Post by Zireael »

Whatever, a ship is not a boolean in any case :P
dertien
---- E L I T E ----
---- E L I T E ----
Posts: 471
Joined: Sun Jan 23, 2011 9:27 pm
Location: Belgium, Monarchy, Feudal, Overtaxed system

Re: Scripters cove

Post by dertien »

Getting there slowly

I was getting a whole lot of these in the log:

Code: Select all

04:20:18.135 [script.javaScript.exception.unexpectedType]: ***** JavaScript exception (HPC Cobra Mk3 ship scripts 1.00): TypeError: player.ship.target is null
04:20:18.135 [script.javaScript.exception.unexpectedType]:       ../AddOns/ZZ_HPC_Cobra_mk3.oxp/Scripts/landing_gear_co3.js, line 167.
Which (I think) was due to this:

Code: Select all

if (this.ship == player.ship && !player.ship.target || !player.ship.target.isStation)
so I changed it to:

Code: Select all

if (this.ship == player.ship || this.ship.target || this.ship.target == null)
Everything still works, and that log error is history; looks like it was unnecessary since it already checked for targetstation in the previous if()

Some more testing later, but now its bedtime again :wink:
Alpha Backer of Elite Dangerous
With 250 GBP :D
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Scripters cove

Post by cim »

dertien wrote:
if (this.ship == player.ship && !player.ship.target || !player.ship.target.isStation)
Brackets. This needs to be

Code: Select all

if (this.ship == player.ship && (!player.ship.target || !player.ship.target.isStation))
If you don't do that, the language interprets it as

Code: Select all

if ((this.ship == player.ship && !player.ship.target) || !player.ship.target.isStation)
which isn't what you want.
dertien wrote:
if (this.ship == player.ship || this.ship.target || this.ship.target == null)
This won't give any errors in the log, but it will always evaluate true and execute whatever's inside the if. If the ship isn't the player ship, then it checks if the target is either something or nothing, and one of those will always be the case.
dertien
---- E L I T E ----
---- E L I T E ----
Posts: 471
Joined: Sun Jan 23, 2011 9:27 pm
Location: Belgium, Monarchy, Feudal, Overtaxed system

Re: Scripters cove

Post by dertien »

Ok, changed that too thanks Cim.

The code up until now does everything right, but I still keep getting an error in the log I want to get rid of; beeing a perfectionist and all....

Code: Select all

this.name      = "HPC Cobra Mk3 ship scripts"; 
this.author    = "Cim, Dertien"; 
this.copyright = "Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0) http://creativecommons.org/licenses/by-nc-sa/3.0/"; 
this.version   = "1.00";

// Cim: So, what you can do is search through the subentities list until you find the one you want.

this._findSubEntity = function(key)
					{
					for (var i = this.ship.subEntities.length - 1 ; i >=0 ; --i)
						{
						if (this.ship.subEntities[i].dataKey == key)
							{
							return this.ship.subEntities[i];
							}
						}
						return null; // couldn't find it.
					}
					
//	reusable function that retracts the gear			
					
this.retractGear = function()

{
   var actuatorsR = this._findSubEntity("HPC_actuatorR"); 
               if (actuatorsR)
               {
                  actuatorsR.position = [0, 6.155206, 2.648078];
               }
	var actuatorsF = this._findSubEntity("HPC_actuatorF");
               if (actuatorsF)
               {
                  actuatorsF.position = [0, 3.80, -21.3];
               }
   var reargearextendPRT = this._findSubEntity("HPC_reargearPRT");
                  if (reargearextendPRT)
               {
               reargearextendPRT.position = [-17.392771, -8.961073, 2.796213];
			   reargearextendPRT.orientation = [0.9953, 0.0908, 0, 0];
               }
   var reargearextendSTB = this._findSubEntity("HPC_reargearSTB");
                  if (reargearextendSTB)
               {
               reargearextendSTB.position = [17.552752, -8.847222, 3.028129];
			   reargearextendPRT.orientation = [-0.9953, -0.0908, 0, 0];
               }
	var frontgearextendPRT = this._findSubEntity("HPC_frontgearPRT");
                  if (frontgearextendPRT)
               {
               frontgearextendPRT.position = [-13.038872, -5.954015, 25.049587];
			   reargearextendPRT.orientation = [0, 0, 0.9959, -0.0905];
               }
	var frontgearextendSTB = this._findSubEntity("HPC_frontgearSTB");
                  if (frontgearextendSTB)
               {
               frontgearextendSTB.position = [13.038872, -5.954015, 25.049587];
			   reargearextendPRT.orientation = [0.9959, 0.0905, 0, 0];
               }
	   
}

//	reusable function that extends the gear

this.extendGear = function()
{

		var actuatorsR = this._findSubEntity("HPC_actuatorR"); 
               if (actuatorsR)
               {
                  actuatorsR.position = [0,0,0];
               }
		var actuatorsF = this._findSubEntity("HPC_actuatorF"); 
               if (actuatorsF)
               {
                  actuatorsF.position = [0,0,0];
               }
		var reargearextendPRT = this._findSubEntity("HPC_reargearPRT");
                  if (reargearextendPRT)
               {
               reargearextendPRT.position = [-17.351349,-17.408951,-3.749173];
               }
		var reargearextendSTB = this._findSubEntity("HPC_reargearSTB");
                  if (reargearextendSTB)
               {
               reargearextendSTB.position = [17.435233,-17.338642,-3.50929];
               }
		var frontgearextendPRT = this._findSubEntity("HPC_frontgearPRT");
                  if (frontgearextendPRT)
               {
               frontgearextendPRT.position = [-12.765342,-11.194131,27.818142];
               }
		var frontgearextendSTB = this._findSubEntity("HPC_frontgearSTB");
                  if (frontgearextendSTB)
               {
               frontgearextendSTB.position = [12.765342,-11.194131,27.818142];
               }
}					



/*
this.npcGearChecker = function()
{
if (this.ship.dockingInstructions)
		{
			this.extendGear();
			player.consoleMessage("NPC TESTER PRIMO");
			this.ship.commsMessage("NPC GEAR DOWN");
			this.ship.commsMessage("NPC DOCKING NOW");
			this.dockingTargetChecker.start();
			return;
		}	
}

*/
// this.npcLandingChecker = new Timer(this, this.npcGearChecker,1, 10);

// functions to switch the navlights on and off

this.switchFlashersOn = function()
{
	this.ship.lightsActive = true; // turns flashers on
}

this.switchFlashersOff = function()
{
	this.ship.lightsActive = false; // turns flashers off
}


this.noDockingComputer = function()
{
    // OPTION 1
	// if target is a station in range lower gear
	if (this.ship.dockingInstructions)
		{
			this.extendGear();
			player.consoleMessage("NPC TESTER");
			this.ship.commsMessage("NPC GEAR DOWN");
			this.ship.commsMessage("NPC DOCKING NOW");
			this.dockingTargetChecker.start();
			return;
		}
	if (this.ship == player.ship && this.ship.target && this.ship.target.isStation && player.ship.position.distanceTo(player.ship.target) < 11000)
		{
			//player.consoleMessage("TEST: Option 1");
			//player.consoleMessage("TEST: SUCCESS TARGET VALID");
			//player.consoleMessage("TEST: SUCCESS GEAR DOWN");
			this.extendGear();
			this.dockingTargetChecker.start();
			return;
		}
	// OPTION 2
	// if target is a station but is too far retract gear
	if (this.ship == player.ship && this.ship.target && this.ship.target.isStation && player.ship.position.distanceTo(player.ship.target) > 11000)
		{
			this.retractGear();
			//player.consoleMessage("Test: Option 2");
			//player.consoleMessage("TEST: PROX WNG");
			//player.consoleMessage("TEST: GEAR UP");
			//this.retractGear();
			this.dockingTargetChecker.start();
			return;
		}
	// OPTION 3
    //if the target is not a station retract gear
	if (this.ship == player.ship && (!player.ship.target || !player.ship.target.isStation))
		{
			this.retractGear();
			//player.consoleMessage("TEST: Option 3");
			//player.consoleMessage("TEST: INVALID TGT");
			//player.consoleMessage("TEST: GEAR UP");
			//this.dockingTargetChecker.start();
			return;
		}
		//return null;
		
}


this.shipEnteredStationAegis = function(station)
{
   this.switchFlashersOn();
}
this.shipExitedStationAegis = function(station)
{
	this.switchFlashersOff();
}

this.shipDockedWithStation = function(station)
{
		this.switchFlashersOn();
		this.extendGear();
		this.dockingTargetChecker.stop();
		//delete this.dockingTargetChecker;
		//this.npcLandingChecker.stop();
		//delete this.npcLandingChecker;
}	

// if the ship launches, show gear deployed and automatically retract after 10 seconds

this.shipLaunchedFromStation = function(station)
{
	this.extendGear();
	this.tenSecTimer = new Timer(this, this.retractGear,10);
	player.consoleMessage("Exiting Station");
	player.consoleMessage("GEAR UP in 10 Sec");
	this.switchFlashersOn();
	//this.dockingTargetChecker.start();
	this.dockingTargetChecker = new Timer(this, this.noDockingComputer,12, 2);
	//this.npcLandingChecker = new Timer(this, this.npcGearChecker,11, 10);
}

// if player hits C key with docking computers active gear drops

this.playerStartedAutoPilot = function()

{
	player.consoleMessage("Docking sequence started");
	player.consoleMessage("GEAR DOWN & LOCKED");
	this.switchFlashersOn();
	this.retractGear();
	this.extendGear();
	this.dockingTargetChecker.stop();
	//delete this.dockingTargetChecker;   
}

// if player cancels docking computers gear retracts

this.playerCancelledAutoPilot = function() 
{
	player.consoleMessage("Docking sequence aborted");
	player.consoleMessage("GEAR UP");
	this.retractGear();
	this.dockingTargetChecker = new Timer(this, this.noDockingComputer,1, 2);
}

// same as shipLaunchedFromStation function

this.shipLeavingPlanetSurface = function(planet)
{
    //player.consoleMessage("Ship Departing");
	player.consoleMessage("Exiting Atmosphere");
	this.extendGear(); 
	this.tenSecTimer = new Timer(this, this.retractGear,10);
	this.dockingTargetChecker = new Timer(this, this.noDockingComputer,11, 2);
	this.ship.commsMessage("GEAR UP 10 Seconds");
}

this.shipWillExitWitchspace = function()
{
    this.switchFlashersOff();
	this.dockingTargetChecker = new Timer(this, this.noDockingComputer,1, 2);
}

// ship drops gear before planetary landing

this.shipApproachingPlanetSurface = function(planet)
{
	 this.extendGear();
	 player.consoleMessage("Entering Atmosphere");
	 player.consoleMessage("GEAR DOWN & LOCKED");
	 this.dockingTargetChecker.stop();
	 //delete this.dockingTargetChecker;
}

this.shipWillEnterWitchspace = function()
{
    this.switchFlashersOff();
	this.dockingTargetChecker.stop();
    //delete this.dockingTargetChecker;
}

this.stationWithdrewDockingClearance = function()
{
	this.retractGear();
	this.dockingTargetChecker.start();
}

this.shipWillLaunchFromStation = function(station)
{
	  this.extendGear();
}

In the log I get this error:

13:21:27.787 [script.javaScript.exception.unexpectedType]: ***** JavaScript exception (HPC Cobra Mk3 ship scripts 1.00): TypeError: this.$dockingTargetChecker is undefined
13:21:27.787 [script.javaScript.exception.unexpectedType]: ../AddOns/ZZ_HPC_Cobra_mk3.oxp/Scripts/landing_gear_co3.js, line 130.

what am I doing wrong ?

This should be the last hurdle for this script. If this works correctly, I can apply the lessons learned here to start using this code for opening the weapon doors and raise the guns, about in the same fashion, (linked to the already implemented active weapons key for the player and depending on state for NPC's should do nicely).

Needless to say that all your posts have brought me this far, an I am grateful for the lessons, since I did learn something. Thank you Cim.
Last edited by dertien on Mon Aug 18, 2014 12:29 pm, edited 1 time in total.
Alpha Backer of Elite Dangerous
With 250 GBP :D
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6570
Joined: Wed Feb 28, 2007 7:54 am

Re: Split: Deployable subentities

Post by another_commander »

Although this topic was initially posted correctly at Scripters' Cove, it has become a full discussion of its own, containing experimental code and multiple attempts to get it right. I think that after 6 pages of this, it has earned its own thread. Topic split.
dertien
---- E L I T E ----
---- E L I T E ----
Posts: 471
Joined: Sun Jan 23, 2011 9:27 pm
Location: Belgium, Monarchy, Feudal, Overtaxed system

Re: Split: Deployable subentities

Post by dertien »

Aah, ok thank you A_C, will keep it in mind for the future.
Alpha Backer of Elite Dangerous
With 250 GBP :D
User avatar
Norby
---- E L I T E ----
---- E L I T E ----
Posts: 2577
Joined: Mon May 20, 2013 9:53 pm
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
Contact:

Re: Scripters cove

Post by Norby »

dertien wrote:
what am I doing wrong ?
I think your ZZ_HPC_Cobra_mk3.oxp/Scripts/landing_gear_co3.js is not equal with your last quote, or maybe you forgot the brick on the shift key. The 130.line is empty where the error happened and there is nowhere $dockingTargetChecker but without $ only.
dertien
---- E L I T E ----
---- E L I T E ----
Posts: 471
Joined: Sun Jan 23, 2011 9:27 pm
Location: Belgium, Monarchy, Feudal, Overtaxed system

Re: Split: Deployable subentities

Post by dertien »

I don't fully grasp what you mean Norby,

But here's the complete log :

Code: Select all

Opening log for Oolite version 1.81 (x86-32 test release) under Windows 6.1.7601 Service Pack 1 64-bit at 2014-08-18 15:28:49 +0200.
8 processors detected.
Build options: OpenAL, new planets, JavaScript console support, OXP verifier, localization tools, debug GraphViz support, JavaScript profiling.

Note that the contents of the log file can be adjusted by editing logcontrol.plist.

15:28:49.713 [dataCache.rebuild.explicitFlush]: Cache explicitly flushed with shift key. Rebuilding from scratch.
15:28:49.815 [display.mode.list.native]: Windows native resolution detected: 1600 x 900
15:28:50.314 [joystick.init]: Number of joysticks detected: 1
15:28:50.321 [rendering.opengl.version]: OpenGL renderer version: 4.4.0 ("4.4.0"). Vendor: "NVIDIA Corporation". Renderer: "GeForce GT 630M/PCIe/SSE2".
15:28:50.321 [rendering.opengl.extensions]: OpenGL extensions (287):
GL_ARB_draw_instanced, GL_NV_float_buffer, GL_NV_vertex_attrib_integer_64bit, GL_ARB_occlusion_query, GL_EXT_texture_env_add, GL_ARB_texture_storage, GL_ARB_texture_env_dot3, GL_ARB_sync, GL_EXTX_framebuffer_mixed_formats, GL_ARB_texture_multisample, GL_ARB_buffer_storage, GL_ARB_explicit_uniform_location, GL_NV_texture_env_combine4, GL_NV_bindless_multi_draw_indirect, GL_ARB_compute_variable_group_size, GL_ARB_point_parameters, GL_ARB_vertex_array_object, GL_NVX_gpu_memory_info, GL_NV_vertex_buffer_unified_memory, GL_ARB_blend_func_extended, GL_NV_explicit_multisample, GL_EXT_provoking_vertex, GL_NV_texture_shader2, GL_EXT_blend_equation_separate, GL_ARB_compressed_texture_pixel_storage, GL_NV_texture_shader3, GL_ARB_texture_stencil8, GL_ARB_texture_non_power_of_two, GL_ARB_texture_mirrored_repeat, GL_ARB_debug_output, GL_EXT_multi_draw_arrays, GL_NV_fence, GL_ARB_timer_query, GL_ARB_texture_buffer_object, GL_ARB_texture_buffer_range, GL_NV_occlusion_query, GL_EXT_abgr, GL_ARB_vertex_program, GL_NV_shader_buffer_load, GL_ATI_texture_float, GL_ARB_draw_buffers_blend, GL_NV_shader_storage_buffer_object, GL_ARB_viewport_array, GL_KTX_buffer_region, GL_ARB_shadow, GL_NV_light_max_exponent, GL_EXT_texture_cube_map, GL_EXT_texture_compression_dxt1, GL_ARB_shader_atomic_counters, GL_NV_texture_multisample, GL_NV_primitive_restart, GL_EXT_framebuffer_object, GL_EXT_texture_sRGB, GL_ARB_shader_storage_buffer_object, GL_ARB_conservative_depth, GL_ARB_get_program_binary, GL_NV_shader_atomic_float, GL_ARB_multitexture, GL_ARB_clear_texture, GL_NV_half_float, GL_NV_copy_image, GL_NV_path_rendering, GL_NV_register_combiners, GL_ARB_shader_image_size, GL_ARB_sparse_texture, GL_NV_compute_program5, GL_NV_draw_texture, GL_EXT_texture_compression_rgtc, GL_ARB_shader_objects, GL_EXT_blend_func_separate, GL_EXT_bgra, GL_ARB_pixel_buffer_object, GL_ARB_vertex_attrib_64bit, GL_NV_fragment_program2, GL_EXT_Cg_shader, GL_ARB_draw_buffers, GL_EXT_separate_shader_objects, GL_NV_texgen_reflection, GL_ARB_texture_env_crossbar, GL_ARB_fragment_shader, GL_EXT_texture_swizzle, GL_EXT_fog_coord, GL_EXT_vertex_array_bgra, GL_EXT_framebuffer_blit, GL_ARB_shader_draw_parameters, GL_NV_copy_depth_to_color, GL_ARB_texture_compression_rgtc, GL_ARB_sample_shading, GL_NV_vertex_program1_1, GL_ARB_seamless_cube_map, GL_WIN_swap_hint, GL_EXT_texture_shared_exponent, GL_ARB_shading_language_420pack, GL_ARB_shader_subroutine, GL_EXT_geometry_shader4, GL_EXT_direct_state_access, GL_EXT_compiled_vertex_array, GL_NV_parameter_buffer_object2, GL_KHR_debug, GL_ARB_copy_image, GL_ARB_shader_image_load_store, GL_NV_vertex_array_range2, GL_ARB_shading_language_include, GL_EXT_texture_storage, GL_EXT_shader_image_load_store, GL_EXT_separate_specular_color, GL_ARB_vertex_type_2_10_10_10_rev, GL_EXT_vertex_array, GL_ARB_shading_language_100, GL_EXT_framebuffer_multisample_blit_scaled, GL_EXT_rescale_normal, GL_ARB_texture_float, GL_EXT_packed_depth_stencil, GL_EXT_bindable_uniform, GL_ARB_texture_swizzle, GL_ARB_half_float_pixel, GL_EXT_texture_compression_s3tc, GL_EXT_draw_instanced, GL_NV_blend_equation_advanced, GL_ARB_occlusion_query2, GL_NV_transform_feedback, GL_NV_texture_compression_vtc, GL_ARB_texture_rgb10_a2ui, GL_SGIS_texture_lod, WGL_EXT_swap_control, GL_ARB_geometry_shader4, GL_NV_point_sprite, GL_ARB_framebuffer_object, GL_NV_conditional_render, GL_EXT_stencil_two_side, GL_ARB_texture_rg, GL_NV_texture_expand_normal, GL_ARB_color_buffer_float, GL_NV_gpu_program4_1, GL_NV_framebuffer_multisample_coverage, GL_EXT_blend_color, GL_NV_packed_depth_stencil, GL_NV_geometry_shader4, GL_NV_texture_rectangle, GL_ARB_vertex_array_bgra, GL_EXT_texture_integer, GL_EXT_texture_array, GL_ARB_base_instance, GL_EXT_import_sync_object, GL_ARB_shading_language_packing, GL_ARB_fragment_program_shadow, GL_ARB_fragment_layer_viewport, GL_NV_gpu_program4, GL_EXT_texture_buffer_object, GL_NV_vertex_program2_option, GL_NV_gpu_program5, GL_ARB_map_buffer_range, GL_ARB_fragment_program, GL_ARB_copy_buffer, GL_ARB_tessellation_shader, GL_NV_gpu_shader5, GL_S3_s3tc, GL_NV_depth_clamp, GL_EXT_texture_lod_bias, GL_EXT_texture_filter_anisotropic, GL_EXT_draw_buffers2, GL_NV_fragment_program, GL_EXT_secondary_color, GL_ARB_transform_feedback2, GL_ARB_transform_feedback3, GL_ARB_ES3_compatibility, GL_EXT_framebuffer_multisample, GL_ARB_window_pos, GL_IBM_rasterpos_clip, GL_EXT_texture_env_combine, GL_ARB_vertex_shader, GL_ARB_texture_compression_bptc, GL_SGIS_generate_mipmap, GL_ARB_compatibility, GL_ATI_texture_mirror_once, GL_EXT_packed_float, GL_ARB_texture_border_clamp, GL_ARB_explicit_attrib_location, GL_NV_blend_square, GL_ARB_internalformat_query, GL_EXT_texture3D, GL_ARB_arrays_of_arrays, GL_SUN_slice_accum, GL_ARB_robust_buffer_access_behavior, GL_NV_vertex_array_range, GL_ARB_ES2_compatibility, GL_NV_vertex_program, GL_ARB_texture_query_lod, GL_NV_multisample_filter_hint, GL_ARB_invalidate_subdata, GL_EXT_texture_mirror_clamp, GL_EXT_texture_sRGB_decode, GL_ARB_texture_compression, GL_NV_vertex_program2, GL_NV_multisample_coverage, GL_ARB_texture_env_add, GL_ARB_imaging, GL_NV_vertex_program3, GL_ARB_provoking_vertex, GL_ARB_framebuffer_no_attachments, GL_EXT_gpu_shader4, GL_ARB_texture_rectangle, GL_OES_compressed_ETC1_RGB8_texture, GL_EXT_texture_edge_clamp, GL_NV_transform_feedback2, GL_ARB_multi_draw_indirect, GL_ARB_draw_elements_base_vertex, GL_ARB_fragment_coord_conventions, GL_NV_gpu_program5_mem_extended, GL_ARB_separate_shader_objects, GL_SGIX_shadow, GL_ARB_texture_cube_map, GL_NV_ES1_1_compatibility, GL_EXT_transform_feedback2, GL_ARB_vertex_attrib_binding, GL_EXT_framebuffer_sRGB, GL_ARB_clear_buffer_object, GL_NV_fragment_program_option, GL_ARB_query_buffer_object, GL_EXT_texture_compression_latc, GL_ARB_vertex_type_10f_11f_11f_rev, GL_ARB_robustness, GL_ARB_point_sprite, GL_ARB_texture_gather, GL_ARB_texture_buffer_object_rgb32, GL_ARB_internalformat_query2, GL_NV_depth_buffer_float, GL_ARB_depth_texture, GL_EXT_texture_object, GL_EXT_depth_bounds_test, GL_NV_fog_distance, GL_ARB_instanced_arrays, GL_EXT_blend_minmax, GL_ARB_compute_shader, GL_SGIX_depth_texture, GL_ATI_draw_buffers, GL_ARB_enhanced_layouts, GL_ARB_multi_bind, GL_ARB_framebuffer_sRGB, GL_EXT_blend_subtract, GL_NV_register_combiners2, GL_EXT_packed_pixels, GL_IBM_texture_mirrored_repeat, GL_NV_texture_shader, GL_EXT_draw_range_elements, GL_ARB_texture_mirror_clamp_to_edge, GL_ARB_texture_cube_map_array, GL_ARB_sampler_objects, GL_ARB_half_float_vertex, GL_ARB_shader_precision, GL_ARB_gpu_shader5, GL_ARB_depth_clamp, GL_ARB_texture_storage_multisample, GL_ARB_transpose_matrix, GL_NV_parameter_buffer_object, GL_ARB_vertex_buffer_object, GL_ARB_texture_query_levels, GL_ARB_draw_indirect, GL_AMD_multi_draw_indirect, GL_EXT_pixel_buffer_object, GL_EXT_vertex_attrib_64bit, GL_ARB_transform_feedback_instanced, GL_ARB_texture_view, GL_NVX_conditional_render, GL_ARB_texture_env_combine, GL_ARB_shader_group_vote, GL_ARB_indirect_parameters, GL_ARB_shader_bit_encoding, GL_EXT_timer_query, GL_EXT_gpu_program_parameters, GL_ARB_shader_texture_lod, GL_ARB_program_interface_query, GL_ARB_uniform_buffer_object, GL_ARB_multisample, GL_EXT_texture_env_dot3, GL_NV_shader_atomic_counters, GL_EXT_shadow_funcs, GL_ARB_stencil_texturing, GL_EXT_texture_lod, GL_ARB_depth_buffer_float, GL_NV_pixel_data_range, GL_ARB_map_buffer_alignment, GL_ARB_gpu_shader_fp64, GL_EXT_stencil_wrap, GL_EXT_point_parameters, GL_NV_texture_barrier, GL_NV_gpu_program_fp64
15:28:50.330 [rendering.opengl.shader.support]: Shaders are supported.
15:28:50.491 [dataCache.rebuild.explicitFlush]: Cache explicitly flushed with shift key. Rebuilding from scratch.
15:28:50.492 [dataCache.rebuild.explicitFlush]: Cache explicitly flushed with shift key. Rebuilding from scratch.
15:28:50.493 [searchPaths.dumpAll]: Resource paths: 
    Resources
    ../AddOns
    ../AddOns/LongRangeScanner v0.0.oxp
    ../AddOns/PlanetFall 1.51.oxp
    ../AddOns/Povray_Planets_Galaxy1_Textures_v1.1.oxp
    ../AddOns/Povray_Planets_Galaxy2_Textures.oxp
    ../AddOns/Povray_Planets_Galaxy3_Textures.oxp
    ../AddOns/Povray_Planets_Galaxy4_Textures.oxp
    ../AddOns/Povray_Planets_Galaxy5_Textures.oxp
    ../AddOns/Povray_Planets_Galaxy6_Textures.oxp
    ../AddOns/Povray_Planets_Galaxy7_Textures.oxp
    ../AddOns/Povray_Planets_Galaxy8_Textures.oxp
    ../AddOns/YOUR_AD_HERE_4.1.7.oxp
    ../AddOns/YOUR_AD_HERE_set_A_4.1.7.oxp
    ../AddOns/YOUR_AD_HERE_set_B_4.1.7.oxp
    ../AddOns/YOUR_AD_HERE_set_C_4.1.7.oxp
    ../AddOns/YOUR_AD_HERE_set_D_4.1.7.oxp
    ../AddOns/YOUR_AD_HERE_set_E_4.1.7.oxp
    ../AddOns/YOUR_AD_HERE_set_F_4.1.7.oxp
    ../AddOns/YOUR_AD_HERE_set_G_4.1.7.oxp
    ../AddOns/ZZ_aOoniverseofCobraMk3s.oxp
    ../AddOns/ZZ_HPC_Cobra_mk3.oxp
    ../AddOns/ZZ_HPC_subents.oxp
15:28:50.685 [shipData.load.begin]: Loading ship data.
15:28:52.844 [startup.complete]: ========== Loading complete in 3.09 seconds. ==========
15:29:09.327 [script.load.world.listAll]: Loaded 25 world scripts:
    LongRangeScanner 0.1
    oolite-cloaking-device 1.81
    oolite-constrictor-hunt 1.81
    oolite-contracts-cargo 1.81
    oolite-contracts-helpers 1.81
    oolite-contracts-parcels 1.81
    oolite-contracts-passengers 1.81
    oolite-libPriorityAI 1.81
    oolite-nova 1.81
    oolite-populator 1.81
    oolite-primable-equipment-register 1.81
    oolite-registership 1.81
    oolite-thargoid-plans 1.81
    oolite-trumbles 1.81
    oolite-tutorial 1.81
    Pi-Forty-Two Con stores 4.1.7
    PlanetFall 1.51
    Povray Planets Galaxy1 Textures 1.1
    Povray Planets Galaxy2 Textures 0.1
    Povray Planets Galaxy3 Textures 0.1
    Povray Planets Galaxy4 Textures 0.1
    Povray Planets Galaxy5 Textures 0.1
    Povray Planets Galaxy6 Textures 0.1
    Povray Planets Galaxy7 Textures 0.1
    Povray Planets Galaxy8 Textures 0.1
15:29:10.078 [script.javaScript.exception.unexpectedType]: ***** JavaScript exception (oolite-populator 1.81): TypeError: h is null
15:29:10.078 [script.javaScript.exception.unexpectedType]:       Resources/Scripts/oolite-populator.js, line 1526.
15:29:10.116 [script.javaScript.exception.unexpectedType]: ***** JavaScript exception (oolite-populator 1.81): TypeError: h is null
15:29:10.116 [script.javaScript.exception.unexpectedType]:       Resources/Scripts/oolite-populator.js, line 1526.
15:29:10.381 [script.javaScript.exception.unexpectedType]: ***** JavaScript exception (oolite-populator 1.81): TypeError: hs is null
15:29:10.381 [script.javaScript.exception.unexpectedType]:       Resources/Scripts/oolite-populator.js, line 1603.
15:29:40.621 [script.javaScript.exception.unexpectedType]: ***** JavaScript exception (HPC Cobra Mk3 ship scripts 1.00): TypeError: this.$dockingTargetChecker is undefined
15:29:40.621 [script.javaScript.exception.unexpectedType]:       ../AddOns/ZZ_HPC_Cobra_mk3.oxp/Scripts/landing_gear_co3.js, line 263.

I always flush the cache with the shift key.

If you meant putting a dollar ($) sign in front it, did not make a difference. Already tried....

Here is the file for testing should you want to have it.

https://app.box.com/s/n6a61qarmglemfwce1ak
Alpha Backer of Elite Dangerous
With 250 GBP :D
User avatar
Norby
---- E L I T E ----
---- E L I T E ----
Posts: 2577
Joined: Mon May 20, 2013 9:53 pm
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
Contact:

Re: Split: Deployable subentities

Post by Norby »

dertien wrote:
Here is the file for testing
Wow, a decent amount of code. :)

The previous error message pointed to the 130. line but now to the 263. line which is better, I suggest to replace all of your stop() calling lines to the following:

Code: Select all

if(this.$dockingTargetChecker) {
   this.$dockingTargetChecker.stop();
   delete this.$dockingTargetChecker;
}
This will avoid the error message when the timer is already stopped.

In general you should use the $ or _ sign in the begin of your global variables and function names, this prevent the malfunction of your OXP in an unlucky case when the core later define a new event handler with the same name. So only the core properties and event handlers should follow the "this." in the code without a $ or _ .
dertien
---- E L I T E ----
---- E L I T E ----
Posts: 471
Joined: Sun Jan 23, 2011 9:27 pm
Location: Belgium, Monarchy, Feudal, Overtaxed system

Re: Split: Deployable subentities

Post by dertien »

Indeed that takes care of the log error, thx Norby.

Now all the code issues have been resolved, I have another question gameplay wise which I do not fully understand.

I have a few copies of the same ship in the shipdata.plist, but depending on their role they have different subentities and weapons which make them all unique. They also have different roles:

Cobra Mk 3 Scavengers
Cobra Mk 3 Couriers
Cobra Mk 3 Haulers
Cobra Mk 3 Sentinel
Cobra Mk 3 Sentinel Hauler

Their names will all go to the Cobra Mk 3 default, when testing is done, to keep the surprise factor up except maybe for the miners, since the default game also shows them with a different name.

What I have seen through testing (simply sitting outside the station and watch traffic go by) is that for example, the Scavenger and the Courier execute the code to deploy their landing gear. And they indeed drop it.

Code: Select all


if (this.ship.dockingInstructions)
      {
         this.extendGear();
         player.consoleMessage("NPC TESTER");
         this.ship.commsMessage("NPC GEAR DOWN");
         this.ship.commsMessage("NPC DOCKING NOW");
         this.dockingTargetChecker.start();
         return;
      }
However, the Cobra Mk 3 Hauler, which has the same AI.js but a different role from the courier does not execute the code and therefore does not drop its landing gear on arrival at the station.

So, for the Cobra Hauler
Changing the role in the shipdata.plist from:

Code: Select all

roles = "trader(0.375) trader-courier(0.2) trader-smuggler(0.75)";
to

Code: Select all

roles = "trader-courier(2) shuttle";
Makes it execute the script.

Now my question is this, why would the role of a ship determine what code gets executed in the ship's script file.

Should not all ships ask for docking instructions ?
Alpha Backer of Elite Dangerous
With 250 GBP :D
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: Split: Deployable subentities

Post by Eric Walch »

One piece of code that is also needed in shipscripts that use timers:

Code: Select all

this.entityDestroyed = function ()
{
    this.$cleanupTimers();
}
And in this.$cleanupTimers you have the code to stop and delete the timer. This is to prevent errors when the ship explodes while there is still a timer running.
Post Reply