Problem with "shipWillLaunchFromStation" event.

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

Moderators: winston, another_commander

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

Problem with "shipWillLaunchFromStation" event.

Post by phkb »

I'm having trouble reseting some variables when the player launches from a station. This is what I have:

Code: Select all

this.shipWillLaunchFromStation = function() {
	this.$commsList = "";
	this.$page = 1;
	this.$updateMFD();
}
I'm trying to reset $commsList to be an empty string, reseting the $page to 1, and forcing a redraw of the multi-function display.
But this code never seems to run, because $commsList is not getting reset between launches. It just keeps growing.
Am I missing something? No errors in the log. The rest of my code seems to work, including this.commsMessageReceived.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: Problem with "shipWillLaunchFromStation" event.

Post by Thargoid »

What format is this.$commslist, a string or an array? The above should reset a string, but to clear an array you need =[] instead of ="".

It may help to add a log line in there too to confirm that the event is triggering or not explicitly.
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4830
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Problem with "shipWillLaunchFromStation" event.

Post by phkb »

It's just a string, not an array. I'll try putting the log entry in.
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4830
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Problem with "shipWillLaunchFromStation" event.

Post by phkb »

OK, now I'm confused. I didn't get any log record when I put an log call in the function. I thought, "Ah, so it's not getting called at all.". Then I thought, just as a test, I'll put a log message into the function I know *is* getting called. And still no message in the log!

It was going so well, too....

So this is what I have. I know this function is getting called, but the log call is not putting anything in the log

Code: Select all

this.commsMessageReceived = function(message, sender) {
	var msg = sender.displayName + ": " + message;
	log(this.name, "comms::" + msg);
	...more code...
	}
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: Problem with "shipWillLaunchFromStation" event.

Post by Norby »

Maybe you are not placed your code into a worldScript (for example "AddOns/Your.oxp/Config/script.js"), or there is a parse error in your file which put an error into your log.
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: Problem with "shipWillLaunchFromStation" event.

Post by Eric Walch »

Or there is a syntax error somewhere and the whole script does not run?
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4830
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Problem with "shipWillLaunchFromStation" event.

Post by phkb »

Found something. It appears to be some sort of caching issue. I renamed the folder my OXP is in, and suddenly everything started working!

So, next question (and I know I've seen the answer to this somewhere), how do you force Oolite to clear this cache (or whatever it is)?
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: Problem with "shipWillLaunchFromStation" event.

Post by Eric Walch »

Put a brick on your shift key during development. :)

When you do a lot of oxp testing, then visit the [wiki]Hidden_Settings_in_Oolite[/wiki] page and set "always-flush-cache" to true. It saves a lot of frustration.
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4830
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Problem with "shipWillLaunchFromStation" event.

Post by phkb »

Thanks! Brick now firmly planted in forehead on shift key.
Post Reply