JS bug-squashing

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
Chaky
Deadly
Deadly
Posts: 213
Joined: Sat Aug 15, 2009 6:15 am

JS bug-squashing

Post by Chaky »

I'm trying to troubleshoot my latest trunk oolite, and I came to a bug that is too tough for my boot.

log reports this (the rest is snipped):

Code: Select all

[script.javaScript.warning.undefinedProp]: ----- JavaScript warning ("Blackjacksbullion witness death actions" 1.2 javascript version): reference to undefined property this.ship
[script.javaScript.warning.undefinedProp]:       ../AddOns/BlackJack's Bullion v1.21.oxp/Scripts/witness.js, line 10.
[script.javaScript.exception.noProperties]: ***** JavaScript exception ("Blackjacksbullion witness death actions" 1.2 javascript version): TypeError: this.ship has no properties
[script.javaScript.exception.noProperties]:       ../AddOns/BlackJack's Bullion v1.21.oxp/Scripts/witness.js, line 10.
Now, scripts included with this OXP are as following:

blackjacks.js

Code: Select all

this.name        = "Blackjacksbullion"
this.author      = "Rustybolts"
this.copyright   = "Do with as you wish"
this.description = "Starts in Galaxy 2 at Telace."
this.version     = "1.2 javascript version"

this.shipDockedWithStation = function()
{
	if (guiScreen != "GUI_SCREEN_MISSION" && player.ship.dockedStation.isMainStation && galaxyNumber==1 && !missionVariables.bolts && system.ID==241)
	{
		mission.runMissionScreen('revengebolts_briefing','pod.png')
		mission.setInstructionsKey ('bolts1')
		missionVariables.bolts='STAGE1'
	}
	if (guiScreen != "GUI_SCREEN_MISSION" && galaxyNumber==1 && player.ship.dockedStation.isMainStation && missionVariables.bolts == 'STAGE2')
	{
		mission.runMissionScreen('revengebolts_firearms','firearms.png')
		mission.setInstructionsKey ("bolts2")
		missionVariables.bolts='STAGE3'
	}
	if (guiScreen != "GUI_SCREEN_MISSION" && galaxyNumber==1 && player.ship.dockedStation.isMainStation && missionVariables.bolts == 'STAGE3' && system.ID==233)
	{
		mission.runMissionScreen('revengebolts_robbery', null)
		player.ship.awardCargo("Firearms",1)
		missionVariables.bolts='STAGE4'
		mission.setInstructionsKey ('bolts3')
	}
	if (guiScreen != "GUI_SCREEN_MISSION" && galaxyNumber==1 && player.ship.dockedStation.isMainStation && missionVariables.bolts == 'STAGE4' && system.ID==127)
	{
		mission.runMissionScreen('revengebolts_flee','vipers.png')
		player.ship.bounty = 64
		missionVariables.bolts='STAGE5'
		mission.setInstructionsKey ('bolts4')
	}
	if (missionVariables.bolts=='STAGE5')
	{
		player.ship.bounty = 64
	}
	if (missionVariables.bolts=='STAGE6')
	{
		player.ship.bounty = 64
	}
	if (guiScreen != "GUI_SCREEN_MISSION" && galaxyNumber==1 && player.ship.dockedStation.isMainStation && missionVariables.bolts == 'STAGE6' && system.ID==67)
	{
		mission.runMissionScreen('revengebolts_finnish','end.png')
		player.credits+=9500
		missionVariables.bolts='STAGE99'
		player.ship.bounty = 0
		mission.setInstructionsKey(null)
	}
}
this.shipExitedWitchspace = function()
{
	if (system.ID==99 && galaxyNumber==1 && missionVariables.bolts=='STAGE5')
	{
		system.legacy_addSystemShips("witness", 1, 0.10)
	}
	if (system.ID==88 && galaxyNumber==1 && missionVariables.bolts=='STAGE1')
	{
		system.legacy_addSystemShips("bolts", 1, 0.10)
	}
}
this.tickle = function()
{
	if (missionVariables.bolts=='STAGE6')
	{
	mission.setInstructionsKey ('bolts5')
	}
}
bolts.js

Code: Select all

this.name        = "Blackjacksbullion death actions"
this.author      = "Rustybolts"
this.copyright   = "Do with as you wish"
this.description = "Runs script for death of bolts"
this.version     = "1.2 javascript version"

this.shipDied = function()
{
	if (system.ID==88 && galaxyNumber==1 && missionVariables.bolts=='STAGE1')
	{
		player.ship.awardCargo("Gold",20)
		player.consoleMessage("20 Gold Scooped")
		missionVariables.bolts='STAGE2'
	}
}
and witness.js

Code: Select all

this.name        = "Blackjacksbullion witness death actions"
this.author      = "Rustybolts"
this.copyright   = "Do with as you wish"
this.description = "Runs script for death of witness"
this.version     = "1.2 javascript version"

this.shipDied = function()
{
	missionVariables.bolts='STAGE6'
	this.ship.commsMessage("Nooooooooooooo!!")
}
I'm open to suggestions.

Also, you should know that I am more-or-less definite noob to JS and I don't fully understand the script structure. (If I did, I wouldn't be posting this I guess)

P.S. This is more of educatonal purpose, than anything else. That's why I'm not bugging the author. Hey, what can I do? I like to learn as I go.

P.P.S. it is 1.73.0.2309 on 32-bit XP.
User avatar
Kaks
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3009
Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke

Post by Kaks »

Hmm, methinks you could have definitely bugged the author on this one, since I doubt that any witness ever screamed in agony when killed...

When the event this.shipDied is called the ship is actually dead, it's an ex-ship, it's gone to meet its maker, etc...

Therefore the this.ship entity (being dead, etc...) doesn't exist anymore by the time that part of the script is called. Hence the error messages you're getting...

I'm happy to be proved wrong, though!

PS: if you want a more comprehensive breakdown of those errors: the first one tells you 'this.ship' is actually not there, the second tells you that this.ship can't have commsMessage, since commsMessage would be a property (ok, it's a function, but in js functions can be properties of objects) of something that doesn't actually exist..
Last edited by Kaks on Mon Aug 24, 2009 8:01 pm, edited 1 time in total.
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
Chaky
Deadly
Deadly
Posts: 213
Joined: Sat Aug 15, 2009 6:15 am

Post by Chaky »

Hmm. makes sense.

So, this is a matter of concept. Not some sintax error. I guess it will take more JS understanding to make that witness behave as author imagined it.
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

Kaks wrote:
Therefore the this.ship entity (being dead, etc...) doesn't exist anymore by the time that part of the script is called. Hence the error messages you're getting...
It is still available. You can even initiate AI action on death actions.

That oxp has other bugs. i.e. The ship scripts are also defined as world scripts I noticed. Bug report could be related to this.
Kaks wrote:
Hmm, methinks you could have definitely bugged the author on this one, since I doubt that any witness ever screamed in agony when killed...
Thargoids do :twisted:
User avatar
Kaks
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3009
Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke

Post by Kaks »

I stand very much corrected! :)

Still, by the time line 10 of witness.js is reached oolite is telling us that this.ship doesn't exist anymore. I wonder what entity is actually executing that witness.js...

I'm having 'fun' with testing other stuff atm, but it would be nice to know!
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

Eric Walch wrote:
The ship scripts are also defined as world scripts I noticed. Bug report could be related to this.
Nail on the head.
User avatar
Svengali
Commander
Commander
Posts: 2370
Joined: Sat Oct 20, 2007 2:52 pm

Post by Svengali »

Rustybolts has already fixed it - v1.23 is available.
Chaky
Deadly
Deadly
Posts: 213
Joined: Sat Aug 15, 2009 6:15 am

Post by Chaky »

... which was yesterday... DOH!

I wish there was some sort of centralized OXP database...
User avatar
Nemoricus
---- E L I T E ----
---- E L I T E ----
Posts: 388
Joined: Mon May 18, 2009 8:51 pm

Post by Nemoricus »

Is this what you're looking for?
Dream as if you'll live forever
Live as if you'll die tomorrow
Chaky
Deadly
Deadly
Posts: 213
Joined: Sat Aug 15, 2009 6:15 am

Post by Chaky »

If it contained all OXPs and a way to notify ppl, yes.
User avatar
Nemoricus
---- E L I T E ----
---- E L I T E ----
Posts: 388
Joined: Mon May 18, 2009 8:51 pm

Post by Nemoricus »

Well, it doesn't contain a notification system, but it's the most comprehensive listing of OXPs there is.
Dream as if you'll live forever
Live as if you'll die tomorrow
User avatar
Svengali
Commander
Commander
Posts: 2370
Joined: Sat Oct 20, 2007 2:52 pm

Post by Svengali »

Chaky wrote:
If it contained all OXPs and a way to notify ppl, yes.
It's in the hands of every oxper to keep it up-to-date, like every other list we could offer.
Post Reply