Page 1 of 1
Problem with "shipWillLaunchFromStation" event.
Posted: Wed Jul 09, 2014 11:40 am
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.
Re: Problem with "shipWillLaunchFromStation" event.
Posted: Wed Jul 09, 2014 11:51 am
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.
Re: Problem with "shipWillLaunchFromStation" event.
Posted: Wed Jul 09, 2014 10:03 pm
by phkb
It's just a string, not an array. I'll try putting the log entry in.
Re: Problem with "shipWillLaunchFromStation" event.
Posted: Wed Jul 09, 2014 10:45 pm
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...
}
Re: Problem with "shipWillLaunchFromStation" event.
Posted: Wed Jul 09, 2014 10:50 pm
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.
Re: Problem with "shipWillLaunchFromStation" event.
Posted: Wed Jul 09, 2014 10:58 pm
by Eric Walch
Or there is a syntax error somewhere and the whole script does not run?
Re: Problem with "shipWillLaunchFromStation" event.
Posted: Wed Jul 09, 2014 10:58 pm
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)?
Re: Problem with "shipWillLaunchFromStation" event.
Posted: Wed Jul 09, 2014 11:03 pm
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.
Re: Problem with "shipWillLaunchFromStation" event.
Posted: Wed Jul 09, 2014 11:12 pm
by phkb
Thanks! Brick now firmly planted in forehead on shift key.