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

Split: viewDirectionChanged woes

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

Moderators: another_commander, winston

User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4657
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Split: viewDirectionChanged woes

Post by phkb »

Is anything showing up in your "latest.log" file? If everything is working OK, you should see your OXP name in the list of loaded OXP's. If there's a problem you could see a Javascript error or a message indicating a problem reading a plist file.
BladeRunner
Average
Average
Posts: 13
Joined: Sat Jun 20, 2015 1:06 am

Re: Split: viewDirectionChanged woes

Post by BladeRunner »

cheers, looking into it now.
10:34:31.967 [script.javaScript.exception.curlyAfterBody]: ***** JavaScript exception (view.myship.js.anon-script): SyntaxError: missing } after function body
10:34:31.968 [script.javaScript.load.failed]: ***** Error loading JavaScript script ../AddOns/myship.oxz/Scripts/view.myship.js -- compilation failed
10:34:31.968 [script.load.notFound]: ***** ERROR: Could not find script file view.myship.js.
BladeRunner
Average
Average
Posts: 13
Joined: Sat Jun 20, 2015 1:06 am

Re: Split: viewDirectionChanged woes

Post by BladeRunner »

Fixed that last one...

now this:
14:19:39.664 [LogEvents]: Player launched from Coriolis Station 25176
14:19:39.672 [Total_patrol]: Adding additional police.
14:19:39.680 [Total_patrol]: Adding additional police.
14:19:40.976 [LogEvents]: Player VIEW_AFT
14:19:41.528 [script.javaScript.unrootedTimer]: ----- WARNING: Timer <OOJSTimer 0x251071b0>{nextTime: 9.075, one-shot, running, function: anonymous} is being garbage-collected while still running. You must keep a reference to all running timers, or they will stop unpredictably!
14:19:41.528 [script.javaScript.unrootedTimer]: ----- WARNING: Timer <OOJSTimer 0x25109f10>{nextTime: 9.075, one-shot, running, function: anonymous} is being garbage-collected while still running. You must keep a reference to all running timers, or they will stop unpredictably!
14:19:41.528 [script.javaScript.unrootedTimer]: ----- WARNING: Timer <OOJSTimer 0x251053b0>{nextTime: 9.075, one-shot, running, function: anonymous} is being garbage-collected while still running. You must keep a reference to all running timers, or they will stop unpredictably!
14:19:41.528 [script.javaScript.unrootedTimer]: ----- WARNING: Timer <OOJSTimer 0x3312aa70>{nextTime: 8.554, one-shot, running, function: anonymous} is being garbage-collected while still running. You must keep a reference to all running timers, or they will stop unpredictably!
14:19:41.528 [script.javaScript.unrootedTimer]: ----- WARNING: Timer <OOJSTimer 0x33127ef0>{nextTime: 8.554, one-shot, running, function: anonymous} is being garbage-collected while still running. You must keep a reference to all running timers, or they will stop unpredictably!
14:19:41.528 [script.javaScript.unrootedTimer]: ----- WARNING: Timer <OOJSTimer 0x33111930>{nextTime: 8.554, one-shot, running, function: anonymous} is being garbage-collected while still running. You must keep a reference to all running timers, or they will stop unpredictably!
14:19:41.863 [LogEvents]: Player VIEW_PORT
14:19:42.281 [LogEvents]: Player VIEW_STARBOARD
14:19:43.167 [LogEvents]: Player VIEW_FORWARD
Still no change in the views... grrrr.

should I try dumping all my extra addons and try with vanilla oolite?
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2676
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: Split: viewDirectionChanged woes

Post by spara »

BladeRunner wrote:
should I try dumping all my extra addons and try with vanilla oolite?
Yes. And you might want to get the developer release. It gives more detailed error information.
BladeRunner
Average
Average
Posts: 13
Joined: Sat Jun 20, 2015 1:06 am

Re: Split: viewDirectionChanged woes

Post by BladeRunner »

cool, will give it a go, thanks for the help...
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2676
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: Split: viewDirectionChanged woes

Post by spara »

BladeRunner wrote:

Code: Select all

this.name	        = "view-myship";
this.author			= "BR";
this.copyright		= "Creative Commons: attribution, non-commercial, sharealike.";
this.description	= "Ship's HUD View";
this.version		= "1.0";

this.viewDirectionChanged = function(viewString)
  {
    if (viewString === "VIEW_CUSTOM")
    {
       var p = player.ship;
		   switch (viewString) {
				      case "VIEW_FORWARD":
					 p.hud = "myship-hud-fore.plist";
					 break;
				      case "VIEW_AFT":
					 p.hud = "myship-hud-aft.plist";
					 break;
				      case "VIEW_PORT":
					 p.hud = "myship-hud-port.plist";
					 break;
				      case "VIEW_STARBOARD":
					 p.hud = "myship-hud-star.plist";
					 break;
		   
    }
  }
Hmmm. This won't work. Apart from that missing, bracket you've corrected, you're first checking that viewString is "VIEW_CUSTOM" and then you're checking cases where viewString is "VIEW_FORWARD", "VIEW_AFT", "VIEW_PORT" or "VIEW_STARBOARD". That naturally does not work. Drop that "VIEW_CUSTOM" check and it should work.
BladeRunner
Average
Average
Posts: 13
Joined: Sat Jun 20, 2015 1:06 am

Re: Split: viewDirectionChanged woes

Post by BladeRunner »

nailed it, thanks!
BladeRunner
Average
Average
Posts: 13
Joined: Sat Jun 20, 2015 1:06 am

Re: Split: viewDirectionChanged woes

Post by BladeRunner »

If you could be so kind as to point me in the right direction for hiding the custom hud screens when viewing the manifest (etc) in flight and the fore hud when docked?

Cheers.
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4657
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Split: viewDirectionChanged woes

Post by phkb »

In your switch statement, add

Code: Select all

        case "VIEW_GUI_DISPLAY":
and then you can decide what you want to do, possibly switching to a another HUD that is designed for use with the GUI screens (like the manifest).

For the docked HUD, you can either add HUD elements with the "alertCondition" set to 1 (docked), and make sure all the other elements have their "alertCondition" set to 14 (status green, yellow and red); or you can create a docked HUD that just has the elements you want, and switch to it like you're doing with the other view directions.

Does that make sense?
BladeRunner
Average
Average
Posts: 13
Joined: Sat Jun 20, 2015 1:06 am

Re: Split: viewDirectionChanged woes

Post by BladeRunner »

cheers, will look into it soon and get back if there are issues.

Again, thanks for your help with this.
Post Reply