Join us at the Oolite Anniversary Party -- London, 7th July 2024, 1pm
More details in this thread.

[RELEASE] LongRangeScanner

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

Moderators: winston, another_commander

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: [RELEASE] LongRangeScanner

Post 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.
User avatar
Okti
---- E L I T E ----
---- E L I T E ----
Posts: 700
Joined: Sun Sep 26, 2010 1:51 pm
Location: A GH shop, near witchpoint to Oresrati in Galaxy 8

Re: [RELEASE] LongRangeScanner

Post 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
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Re: [RELEASE] LongRangeScanner

Post 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.
User avatar
Okti
---- E L I T E ----
---- E L I T E ----
Posts: 700
Joined: Sun Sep 26, 2010 1:51 pm
Location: A GH shop, near witchpoint to Oresrati in Galaxy 8

Re: [RELEASE] LongRangeScanner

Post 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
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: [RELEASE] LongRangeScanner

Post 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.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: [RELEASE] LongRangeScanner

Post 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.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Re: [RELEASE] LongRangeScanner

Post 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]
gizmo
Deadly
Deadly
Posts: 157
Joined: Mon Nov 22, 2010 2:40 pm
Location: aboard the "Kiss of Time"

Re: [RELEASE] LongRangeScanner

Post by gizmo »

If this thread continues some more I'll quit Perl, PHP and C and start with JavaScript instead. :D
User avatar
Okti
---- E L I T E ----
---- E L I T E ----
Posts: 700
Joined: Sun Sep 26, 2010 1:51 pm
Location: A GH shop, near witchpoint to Oresrati in Galaxy 8

Re: [RELEASE] LongRangeScanner

Post 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
gizmo
Deadly
Deadly
Posts: 157
Joined: Mon Nov 22, 2010 2:40 pm
Location: aboard the "Kiss of Time"

Re: [RELEASE] LongRangeScanner

Post 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
User avatar
Okti
---- E L I T E ----
---- E L I T E ----
Posts: 700
Joined: Sun Sep 26, 2010 1:51 pm
Location: A GH shop, near witchpoint to Oresrati in Galaxy 8

Re: [RELEASE] LongRangeScanner

Post by Okti »

Have you ever tried a recursive function in RPG II on IBM S36 gizmo,

That will show my age. :)


Okti
gizmo
Deadly
Deadly
Posts: 157
Joined: Mon Nov 22, 2010 2:40 pm
Location: aboard the "Kiss of Time"

Re: [RELEASE] LongRangeScanner

Post by gizmo »

Luckily I never had to deal with RPG - Forth and Mumps were enough to (almost) drive me nuts.
User avatar
Kaks
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3009
Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke

Re: [RELEASE] LongRangeScanner

Post 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! :)
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
User avatar
Okti
---- E L I T E ----
---- E L I T E ----
Posts: 700
Joined: Sun Sep 26, 2010 1:51 pm
Location: A GH shop, near witchpoint to Oresrati in Galaxy 8

Re: [RELEASE] LongRangeScanner

Post by Okti »

Kaks wrote
You will in 1.75!

How?

Okti
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: [RELEASE] LongRangeScanner

Post 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; 
        }
Post Reply