runScreen not always firing when expected to
Moderators: winston, another_commander, Getafix
Re: runScreen not always firing when expected to
I only offered the code example because for the simple case of showing the mission briefing...it works.
- Capt. Murphy
- Commodore
- Posts: 1127
- Joined: Fri Feb 25, 2011 8:46 am
- Location: UK South Coast.
Re: runScreen not always firing when expected to
Why don't you let this.missionScreenOpportunity deal with potential conflicts? Anywhere you want to runScreen, set a flag, and manually call this.missionScreenOpportunity().
Under the event handler function include a condition check for the flag and if met the appropriate runScreen command. It is easy this way to look after multiple screens, daisy chain screens etc. Take a look at the current Explorers' Club to see how the options and associated screens are set up.
Under the event handler function include a condition check for the flag and if met the appropriate runScreen command. It is easy this way to look after multiple screens, daisy chain screens etc. Take a look at the current Explorers' Club to see how the options and associated screens are set up.
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
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
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Re: runScreen not always firing when expected to
I disagree here. Specially when you use it for showing a missionscreen, or adding text to the current screen it is useless. It is not guaranteed that the 'to' screen is the current screen, so you must test for the current screen instead of the 'to' screen. When no other oxp het interacted during this handler, both screens still will be the same.PhantorGorth wrote:It isn't useless if you are launching a mission screen when you go from one particular screen to another particular screen. This is done for my Triple-F5 screen I use in my Visas WIP.Eric Walch wrote:The 'to' in guiScreenChanged() is often a bit of useless in my opinion. In most cases you don't want to know were the original code changed to, but you want to know the page you are currently viewing.
The only time when you can use the 'to' is when just setting a few variables on the action and you are not interested in the actual current screen.
UPS-Courier & DeepSpacePirates & others at the box and some older versions
- PhantorGorth
- ---- E L I T E ----
- Posts: 647
- Joined: Wed May 20, 2009 6:48 pm
- Location: Somewhere off the top left of Galaxy 1 map
Re: runScreen not always firing when expected to
I am considering this.Capt. Murphy wrote:Why don't you let this.missionScreenOpportunity deal with potential conflicts? Anywhere you want to runScreen, set a flag, and manually call this.missionScreenOpportunity().
Under the event handler function include a condition check for the flag and if met the appropriate runScreen command. It is easy this way to look after multiple screens, daisy chain screens etc. Take a look at the current Explorers' Club to see how the options and associated screens are set up.
Chat and relax with other commanders in the [url=irc://irc.oftc.net/oolite]DS's Seedy Space Bar[/url]. The Coolest Bar in the Eight.
Phantor's OXPs: GalCop Rewards and Safe Docking
Phantor's OXPs: GalCop Rewards and Safe Docking
- PhantorGorth
- ---- E L I T E ----
- Posts: 647
- Joined: Wed May 20, 2009 6:48 pm
- Location: Somewhere off the top left of Galaxy 1 map
Re: runScreen not always firing when expected to
The circumstances I am referring to are not about knowing the current screen but about the one you will be going to, to intercept. My Visas' Triple-F5 screen is a mission screen acting as a gui screen to provide information about the Visas you own. It is accessed by pressing F5 on the Manifest screen. Under normal circumstances the screen then displayed is the Status screen but on guiChangeScreen event I use the fact that "from" is GUI_SCREEN_MANIFEST and "to" is GUI_SCREEN_STATUS to launch my mission screen. It doesn't matter which screen the current actually is at that moment just that the screen it's going to is meant to be GUI_SCREEN_STATUS and you are coming from is GUI_SCREEN_MANIFEST. This is purely about navigation of screens, not what is displayed. The only proviso is to make sure that the current screen isn't another mission screen, which caused me a headache for my GalCop_Rewards OXP. When you press space on the Visas' mission screen the screen displayed should be, but doesn't necessarily need to be, the Status screen, but if it is, the navigation looks like I have added a screen to the F5 button cycle which is what I am after.Eric Walch wrote:I disagree here. Specially when you use it for showing a missionscreen, or adding text to the current screen it is useless. It is not guaranteed that the 'to' screen is the current screen, so you must test for the current screen instead of the 'to' screen. When no other oxp het interacted during this handler, both screens still will be the same.PhantorGorth wrote:It isn't useless if you are launching a mission screen when you go from one particular screen to another particular screen. This is done for my Triple-F5 screen I use in my Visas WIP.Eric Walch wrote:The 'to' in guiScreenChanged() is often a bit of useless in my opinion. In most cases you don't want to know were the original code changed to, but you want to know the page you are currently viewing.
The only time when you can use the 'to' is when just setting a few variables on the action and you are not interested in the actual current screen.
Chat and relax with other commanders in the [url=irc://irc.oftc.net/oolite]DS's Seedy Space Bar[/url]. The Coolest Bar in the Eight.
Phantor's OXPs: GalCop Rewards and Safe Docking
Phantor's OXPs: GalCop Rewards and Safe Docking
- Commander McLane
- ---- 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: runScreen not always firing when expected to
There should always be a check forThargoid wrote:Also you seem to check if the player is docked after you've checked two examples of what the docked station will be? Either the check for player.ship.docked is superfluous, or one of the preceding two will fail badly asdockedStation
won't have any properties (as you won't be docked). The order would be better with the dock check first (and in an if statement you don't need==true
, justplayer.ship.docked
is sufficient, the check for true is implicit).
player.ship.docked
first. It's never superfluous. The reason is that it is possible to immediately re-launch the player by script upon docking. Scripts that check for a property of the docked entity (like isMainStation
or another one) will throw an error, because dockedStation is already null
and therefore has no properties. I'm just checking this situation of docking and immediate script-induced re-launch, and Snoopers is giving me this error every time:
Code: Select all
22:24:33.331 [script.javaScript.exception.unexpectedType]: ***** JavaScript exception (snoopers 2.1): TypeError: player.ship.dockedStation is null
Re: runScreen not always firing when expected to
I meant where it is in the posted script it's superfluous (either the preceeding checks self-evidently prove that the player is docked, or the script will bomb out with precisely the kind of error you posted and will never get to the dock check anyway).
You are entirely correct though that the first check should always be that the player is docked. I was speaking specifically about this particular example, which indeed should be rearranged into the correct order.
You are entirely correct though that the first check should always be that the player is docked. I was speaking specifically about this particular example, which indeed should be rearranged into the correct order.
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
Re: runScreen not always firing when expected to
Sure - I'll add a check as it is a valid method and Oolite allows it.Commander McLane wrote:There should always be a check forplayer.ship.docked
first. It's never superfluous. The reason is that it is possible to immediately re-launch the player by script upon docking. Scripts that check for a property of the docked entity (likeisMainStation
or another one) will throw an error, because dockedStation is alreadynull
and therefore has no properties. I'm just checking this situation of docking and immediate script-induced re-launch, and Snoopers is giving me this error every time:Code: Select all
22:24:33.331 [script.javaScript.exception.unexpectedType]: ***** JavaScript exception (snoopers 2.1): TypeError: player.ship.dockedStation is null
But still - it smells like a problematic approach which might have other side-effects...
Re: runScreen not always firing when expected to
Hmm, there seems to be a few issues centred around scripts spitting out the player while they're docking.
There are some plans to overhaul the way docks work in the near-ish future, and including a way to totally prevent the player from docking might well become part of that overhaul...
There are some plans to overhaul the way docks work in the near-ish future, and including a way to totally prevent the player from docking might well become part of that overhaul...
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
Re: runScreen not always firing when expected to
OOoo .-)Kaks wrote:There are some plans to overhaul the way docks work in the near-ish future, and including a way to totally prevent the player from docking might well become part of that overhaul...
And muchas gracias CMcL for the pointer .-)
- Commander McLane
- ---- 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: runScreen not always firing when expected to
That would be nice.Kaks wrote:There are some plans to overhaul the way docks work in the near-ish future, and including a way to totally prevent the player from docking might well become part of that overhaul...
You're welcome.Svengali wrote:And muchas gracias CMcL for the pointer .-)