Page 2 of 5

Re: Split: viewDirectionChanged woes

Posted: Fri Jul 29, 2011 6:35 am
by Killer Wolf
Thanks Common, i'll have a bit more fiddle over the weekend. JS has entirely far too many "="s in statements for me >:-/

Kaks, i have NOD32 running on the machine and SuperAntiSpyware, neither of which i would think should affect a game like Oolite running?

Re: Split: viewDirectionChanged woes

Posted: Fri Jul 29, 2011 11:26 am
by Kaks
The game itself won't have a problem either way, it only affects your ability to debug the game! :)

The second bunch of errors Oolite was giving you:

Code: Select all

17:42:24.529 [debugTCP.disconnect]: No connection to debug console: "Connection to debug console failed: 'No connection could be made because the target machine actively refused it.

' (outStream status: 7, inStream status: 7)."
17:42:24.529 [debugTCP.disconnect]: No connection to debug console: "Connection to debug console failed: 'unknown error.' (outStream status: 0, inStream status: 0)."
17:42:24.529 [debugTCP.connect.failed]: Failed to connect to debug console at address 127.0.0.1:8563.
means:

1) debug.oxp is installed, I assume you want to use the debug console.
2) I've tryed to find the debug console, but no joy.


It's only a 'real' error if you do have the debug console running when Oolite writes those lines to the log: if you do have the console running and Oolite can't find it, it normally means you need to tweak your firewall setting.

If the debug console isn't running, then of course Oolite can't find it... ;)

Re: Split: viewDirectionChanged woes

Posted: Fri Jul 29, 2011 11:36 am
by Killer Wolf
oh. well i don't run the debug console, the oxp was included in trunk so i think i'll just remove it to tidy things up a bit.
ta

Re: Split: viewDirectionChanged woes

Posted: Fri Jul 29, 2011 2:05 pm
by CommonSenseOTB
Have a good weekend KW and good luck. :wink:

Re: Split: viewDirectionChanged woes

Posted: Fri Jul 29, 2011 7:05 pm
by Killer Wolf
>:-/
right. in an attempt to at least see if things were working, i chopped down the new stuff to this :

Code: Select all

   this.viewDirectionChanged = function(viewString)
   {
   if(viewString === "VIEW_GUI_DISPLAY")
         {
			log("GUI!!!!");
               player.ship.hud = "phantomGUI.plist";
		 }
//	else if(player.alertHostiles && player.ship.energy > 108 && viewString !== "VIEW_GUI_DISPLAY")
//		{
//			player.ship.hud = "phantomCombatHUD.plist";
//		}
//	else if(player.ship.energy < 109)
//		{
//		player.ship.hud = "phantomSnafuHUD.plist";
//		}
//	else
//		{
//		player.ship.hud = "phantomNormalHUD.plist";
//		}
	}
i figured that maybe bits of Thargoids stuff is overriding the GUI bit, but when i looked in the log after lots of toing and froing, there wasn't a single "GUI!!" message. is my syntax wrong, or is summat not firing properly?
ta!

Re: Split: viewDirectionChanged woes

Posted: Fri Jul 29, 2011 7:54 pm
by Svengali
Oolite passes two arguments to viewDirectionChanged. The first argument will never be "VIEW_GUI_DISPLAY" as the handler is fired for inflight views (F1-F4 or customviews). You'll have to combine it with guiScreenChanged to handle all cases.

To get a overview you could use

Code: Select all

this.viewDirectionChanged = function(to,from)
{
	log(this.name,"viewDirectionChanged: to:"+to+" from:"+from);
}
this.guiScreenWillChange = function(to,from)
{
	log(this.name,"guiScreenWillChange: to:"+to+" from:"+from);
}
this.guiScreenChanged = function(to,from)
{
	log(this.name,"guiScreenChanged: to:"+to+" from:"+from);
}

Re: Split: viewDirectionChanged woes

Posted: Sat Jul 30, 2011 5:42 am
by Killer Wolf
oh. well that seems a critical bit of info missed off the wiki :-/

cheers. back to the drawing board...
can i not just use "if (from ===" etc etc, in my above code?

Re: Split: viewDirectionChanged woes

Posted: Sat Jul 30, 2011 8:36 am
by Thargoid
Yes you can. Svengali's code just logs when those events occur and with what parameters. So you can see what's triggering when.

The next step will be to replace the logging with the actual code for swapping HUDS etc (your if statements) based on those parameters.

Re: Split: viewDirectionChanged woes

Posted: Sat Jul 30, 2011 2:49 pm
by CommonSenseOTB
Killer Wolf wrote:
>:-/
right. in an attempt to at least see if things were working, i chopped down the new stuff to this :

Code: Select all

   this.viewDirectionChanged = function(viewString)
   {
   if(viewString === "VIEW_GUI_DISPLAY")
         {
			log("GUI!!!!");
               player.ship.hud = "phantomGUI.plist";
		 }
//	else if(player.alertHostiles && player.ship.energy > 108 && viewString !== "VIEW_GUI_DISPLAY")
//		{
//			player.ship.hud = "phantomCombatHUD.plist";
//		}
//	else if(player.ship.energy < 109)
//		{
//		player.ship.hud = "phantomSnafuHUD.plist";
//		}
//	else
//		{
//		player.ship.hud = "phantomNormalHUD.plist";
//		}
	}
i figured that maybe bits of Thargoids stuff is overriding the GUI bit, but when i looked in the log after lots of toing and froing, there wasn't a single "GUI!!" message. is my syntax wrong, or is summat not firing properly?
ta!
KW, have you tried this?

Code: Select all

   this.viewDirectionChanged = function()
   {
   if(player.ship.viewDirection === "VIEW_GUI_DISPLAY")
         {
			log("GUI!!!!");
               player.ship.hud = "phantomGUI.plist";
		 }
	else if((player.alertHostiles) && (player.ship.energy > 108) && (player.ship.viewDirection !== "VIEW_GUI_DISPLAY"))
)
		{
			player.ship.hud = "phantomCombatHUD.plist";
		}
	else if(player.ship.energy < 109)
		{
		player.ship.hud = "phantomSnafuHUD.plist";
		}
	else
		{
		player.ship.hud = "phantomNormalHUD.plist";
		}
	}
This sort of thing works in the numeric hud using a !== so should work here as well. :)

Re: Split: viewDirectionChanged woes

Posted: Sat Jul 30, 2011 5:43 pm
by Killer Wolf
just tried, doesn't work.
i'll cobble something using the stuff Svengali mentioned. think it's going to bea right effing bodged job tho :-D

Re: Split: viewDirectionChanged woes

Posted: Sat Jul 30, 2011 6:44 pm
by Svengali
Killer Wolf wrote:
think it's going to bea right effing bodged job tho :-D
He, that's the fun of scripting (and coding) I'd think. And we really shouldn't forget that viewDirectionChanged is under development and more or less a moving target .-)

Re: Split: viewDirectionChanged woes

Posted: Sat Jul 30, 2011 9:04 pm
by CommonSenseOTB
Svengali wrote:
Killer Wolf wrote:
think it's going to bea right effing bodged job tho :-D
He, that's the fun of scripting (and coding) I'd think. And we really shouldn't forget that viewDirectionChanged is under development and more or less a moving target .-)
I have a question: How many "elses" can follow an "if"?

Re: Split: viewDirectionChanged woes

Posted: Sat Jul 30, 2011 9:28 pm
by Mauiby de Fug
CommonSenseOTB wrote:
I have a question: How many "elses" can follow an "if"?
One, but by coupling that else with an if, as many as you like!

Re: Split: viewDirectionChanged woes

Posted: Sat Jul 30, 2011 10:19 pm
by Dragonfire
Mauiby de Fug wrote:
CommonSenseOTB wrote:
I have a question: How many "elses" can follow an "if"?
One, but by coupling that else with an if, as many as you like!
The only thing I miss from Visual Basic is the Select Case construct...

Re: Split: viewDirectionChanged woes

Posted: Sun Jul 31, 2011 6:38 am
by Killer Wolf
Svengali wrote:
Killer Wolf wrote:
think it's going to bea right effing bodged job tho :-D
He, that's the fun of scripting (and coding) I'd think. And we really shouldn't forget that viewDirectionChanged is under development and more or less a moving target .-)
lol, translates as : as soon as i've spent hours getting it to work, they'll change it!