player.consoleMessage/commsMessage && Hyperspace Countdown.

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

Moderators: winston, another_commander, Getafix

Post Reply
User avatar
Capt. Murphy
Commodore
Commodore
Posts: 1127
Joined: Fri Feb 25, 2011 8:46 am
Location: UK South Coast.

player.consoleMessage/commsMessage && Hyperspace Countdown.

Post by Capt. Murphy »

Hi,

Neither player.consoleMessage or player.commsMessage are displayed on the HUD if called under a this.playerStartedJumpCountdown = function(type) handler - i.e. whilst the Hyperspace Jump Countdown messages are being displayed. If player.commsMessage is used it is logged in the communications log.

My OXP needs to display a warning about unpredictable jump results. :)

Edit: OK I can work around this by using a Timer to repeat the warning - it looks like the core code overrides the display time of scripted messages to prevent HUD untidiness??

Blimey - I've just realised I've subconsciously used JS syntax && in the subject line....must.stop.looking.at.code.... :shock:
[EliteWiki] Capt. Murphy's OXPs
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
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: player.consoleMessage/commsMessage && Hyperspace Countdo

Post by Eric Walch »

Capt. Murphy wrote:
- it looks like the core code overrides the display time of scripted messages to prevent HUD untidiness??
Yes, I think it is clearing all older messages before writing a new time. I had the same with the MisjumpAnalyser.oxp. That also writes a message during countdown. But I added a sound, so you know it triggered and you also see the message in the comms-log like you say.
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: player.consoleMessage/commsMessage && Hyperspace Countdo

Post by Commander McLane »

The other specific problem with the witchjump countdown message is that it's not one, but 15 messages. Each second a new, second-long message is written. Therefore you have to wait for the full time until you can get in another message. There's no sneaking in.

If you want to give the player a chance to read something, you could probably use a commsMessage instead. This brings up the comms log window as well, so he could catch it there. On the other hand, there is no guarantee that he'll notice. I know from myself that I tend to keep my eyes focused on the countdown, so I'd probably miss the comms log window in my peripheral view.
User avatar
Capt. Murphy
Commodore
Commodore
Posts: 1127
Joined: Fri Feb 25, 2011 8:46 am
Location: UK South Coast.

Re: player.consoleMessage/commsMessage && Hyperspace Countdo

Post by Capt. Murphy »

I've got it to reliably intersperse the warning with the countdown using a Timer set at 1 second intervals and to start 1 second after this.playerStartedJumpCountdown.

Code: Select all

this.playerStartedJumpCountdown = function(type)
{
	if (type == "standard" && this.bwd_status == "DAMAGED" && player.ship.equipmentStatus("EQ_BREAKABLE_WITCHDRIVE") != "EQUIPMENT_OK")
	{
		if (!this.bwd_consolemessageTimer)
			{
				this.bwd_consolemessageTimer = new Timer(this, this.bwd_consoleMessage, 1,1);
			}
		else
			{
				this.bwd_consolemessageTimer.start();
			}
}

this.bwd_consoleMessage = function()
{
		player.consoleMessage("Warning - Thruspace HyperDrive is Damaged. Jump Outcome Unpredictable!",1);
}

this.playerCancelledJumpCountdown = this.playerJumpFailed = this.shipWillEnterWitchspace = function()
{
	if (this.bwd_consolemessageTimer && this.bwd_consolemessageTimer.isRunning)
		{
			this.bwd_consolemessageTimer.stop();
			delete this.bwd_consolemessageTimer;
		}
}

[EliteWiki] Capt. Murphy's OXPs
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
Post Reply