Page 4 of 5

Re: [RELEASE] LongRangeScanner

Posted: Mon Feb 14, 2011 8:02 pm
by Eric Walch
Okti wrote:
Is that true for mission screens displayed during flight?
Okti
In your case you already have an exit choice:

Code: Select all

"SCANNER_99_EXIT" = "Exit Long Range Scanner";
So you don't really need the missionScreenEnded. missionScreenEnded could have been from an other similar oxp were you now react on. You currently don't test if it was your oxp that generated the ending.

Better use your callBack for the detection as you have the code already in place as I see it.

Re: [RELEASE] LongRangeScanner

Posted: Mon Feb 14, 2011 8:25 pm
by Okti
Hi Eric, Ahruman,

Being a VB.NET programmer professionaly I am not experienced in JAVA scripts. I know a bit about callbacks. and I have a call back function as you mentioned as having a parameter choice. Can you please give me a clue what I will receive in choice variable when the player presses F1 Key and ends the mission screen during flight?

And as I said I am not used to Java variables as well.

Okti

Re: [RELEASE] LongRangeScanner

Posted: Mon Feb 14, 2011 8:42 pm
by Thargoid
If you are in-flight, then guiScreen will have the value "GUI_SCREEN_MAIN".

If you're in your mission screen it will be "GUI_SCREEN_MISSION", and if you're in the status screen (F5) it will be "GUI_SCREEN_STATUS". There are other values for the other screens available when docked.

You can't tell which view of the flight screen you are in (front, rear etc) but for your requirements that doesn't matter. In your callback you can use this to see if you're still in a mission screen or not.

Re: [RELEASE] LongRangeScanner

Posted: Mon Feb 14, 2011 8:43 pm
by Okti
I just added a line to my callback to log choice when I press F1 during the mission screen and the logged statement is below


[LongRangeScanner]: 7.308248569495833e-307

Does it make sense to anybody. Or as I said earlier, I am a new bie to java scripts, is there


switch
case condition1:
case condition2:
case else

if there is how do you code case else

Okti

Re: [RELEASE] LongRangeScanner

Posted: Mon Feb 14, 2011 8:44 pm
by JensAyton
Okti wrote:
Being a VB.NET programmer professionaly I am not experienced in JAVA scripts. I know a bit about callbacks. and I have a call back function as you mentioned as having a parameter choice. Can you please give me a clue what I will receive in choice variable when the player presses F1 Key and ends the mission screen during flight?
Firstly, JavaScript is not Java. :-)

Secondly: as of r4354, you get null. Until a minute ago, you got an arbitrary value or a crash on some platforms and 0 on others. In 1.74, I expect you get undefined.

Re: [RELEASE] LongRangeScanner

Posted: Mon Feb 14, 2011 8:48 pm
by JensAyton
Okti wrote:
I am a new bie to java scripts, is there


switch
case condition1:
case condition2:
case else

Code: Select all

switch (value)
{
    case a:
        /* do something */;
        break;
        
    case b:
        /* do something */;
        break;
        
    default:
        /* do default thing */;
}
If the break is missing, it will “fall through” to the next case. See the built-in oolite-constrictor-hunt-mission.js for an example.

Re: [RELEASE] LongRangeScanner

Posted: Mon Feb 14, 2011 8:48 pm
by Thargoid
Within your callback function (this.choice or whatever you've called it) just use:

Code: Select all

if(guiScreen === "GUI_SCREEN_MAIN") { code to run if you're currently in the flight screen here }
where the code is what you want to do if the player has left the mission screen via F1-F4. You don't need to reference the choice parameter at all (as nothing will be present there).[/color]

Re: [RELEASE] LongRangeScanner

Posted: Mon Feb 14, 2011 8:54 pm
by gizmo
If this thread continues some more I'll quit Perl, PHP and C and start with JavaScript instead. :D

Re: [RELEASE] LongRangeScanner

Posted: Mon Feb 14, 2011 9:28 pm
by Okti
Thanks Ahruman,


Default worked. :)

Thargoid,

To check the guiScreen did not worked, :(

Gizmo,

The most chalanging think about being a programmer, you never stop learning. most of it is by trial and error but if you got people like the ones in BB to respond you before you finished your next post it is great indeed. :)


Cheers

Okti

Re: [RELEASE] LongRangeScanner

Posted: Mon Feb 14, 2011 9:38 pm
by gizmo
Okti wrote:
The most chalanging think about being a programmer, you never stop learning.
True!

On the other hand: after programming for 2-3 dekades, thereby using at least 15 different programming languages there comes a time in your life where learning isn't that easy anymore.
Am I sounding like a grey beard? Nah! :D

Re: [RELEASE] LongRangeScanner

Posted: Mon Feb 14, 2011 9:47 pm
by Okti
Have you ever tried a recursive function in RPG II on IBM S36 gizmo,

That will show my age. :)


Okti

Re: [RELEASE] LongRangeScanner

Posted: Mon Feb 14, 2011 10:01 pm
by gizmo
Luckily I never had to deal with RPG - Forth and Mumps were enough to (almost) drive me nuts.

Re: [RELEASE] LongRangeScanner

Posted: Mon Feb 14, 2011 10:22 pm
by Kaks
Thargoid wrote:
You can't tell which view of the flight screen you are in (front, rear etc)
You will in 1.75! :)

Re: [RELEASE] LongRangeScanner

Posted: Mon Feb 14, 2011 10:33 pm
by Okti
Kaks wrote
You will in 1.75!

How?

Okti

Re: [RELEASE] LongRangeScanner

Posted: Tue Feb 15, 2011 8:39 am
by Eric Walch
Okti wrote:
Kaks wrote
You will in 1.75!

How?

Okti
See wiki: PlayerShip viewDirection

Code: Select all

        switch (player.ship.viewDirection) {
            case "VIEW_FORWARD": xxxx; break;
            case "VIEW_AFT": xxxx;break;
            case "VIEW_PORT": xxxx;break;
            case "VIEW_STARBOARD": xxxx;break;
            default : xxxx; 
        }