Thanks.Kaks wrote:OK, from tonight's build .viewDirectionChanged should fire correctly. It took me a while to figure out the source of glithches that were plaguing my original implementation...

Moderators: winston, another_commander
Thanks.Kaks wrote:OK, from tonight's build .viewDirectionChanged should fire correctly. It took me a while to figure out the source of glithches that were plaguing my original implementation...
Code: Select all
this.alertConditionChanged = function(newCondition, oldCondition)
{
switch(newCondition)
{
case 0: // we're docked
{
player.ship.hud = "phantomTradingHUD.plist"; // set the docked HUD
break;
}
case 1: // we're at green alert
case 2: // or we're at yellow alert
{
if(player.ship.energy > 108 && player.viewString != "VIEW_GUI_DISPLAY") // if we're not using the damaged HUD
{
player.ship.hud = "phantomNormalHUD.plist"; // set the standard HUD
}
break;
}
case 3: // we're at red alert
{
if(player.alertHostiles && player.ship.energy > 108 && player.viewString != "VIEW_GUI_DISPLAY") // and under attack and not using the damaged HUD
{
player.ship.hud = "phantomCombatHUD.plist"; // set the combat HUD
}
break;
}
case 4:
{
if (viewString == "VIEW_GUI_DISPLAY")
{
player.ship.hud = "phantomGUI.plist";
}
}
}
}
this.shipLaunchedFromStation = function()
{
if(this.energyCheckTimer)
{
this.energyCheckTimer.start()
}
else
{
this.energyCheckTimer = new Timer(this, this.energyCheck,0,2) // use a timer to keep an eye on the HUD state
}
}
this.energyCheck = function()
{
if(player.ship.docked)
{
this.energyCheckTimer.stop();
}
else
{
if(player.ship.energy < 109 )
{
player.ship.hud = "phantomSnafuHUD.plist"; // display the damaged HUD
return;
}
if(player.ship.energy > 108 && player.ship.hud == "phantomSnafuHUD.plist")
{
this.alertConditionChanged(player.alertCondition,0); // if energy is >49 and we're still displaying the damaged HUD, use other code to repair
}
}
}
this.shipDied = function()
{
if(this.energyCheckTimer)
{
this.energyCheckTimer.stop()
}
}
There is no alert condition 4. Your options are 0-3.Killer Wolf wrote:okay, still not working.
here's my script :Code: Select all
this.alertConditionChanged = function(newCondition, oldCondition) { switch(newCondition) { case 0: // we're docked ... case 4: { if (viewString == "VIEW_GUI_DISPLAY") { player.ship.hud = "phantomGUI.plist";
No, because he has mistaken this.alertConditionChanged for magic.Kaks wrote:Never mind that!
I'm not surprised it's not working, KW's code hasn't got this.viewDirectionChanged anywhere I can see...
or maybe i just tried changing some code? pardon me for not being a fkng JS expert.Wildeblood wrote:No, because he has mistaken this.alertConditionChanged for magic.Kaks wrote:Never mind that!
I'm not surprised it's not working, KW's code hasn't got this.viewDirectionChanged anywhere I can see...
Don't react like that, my comment was deadpan irony, not an outrageous insult. JS isn't magical, it's just evil and bogus. But you have misunderstood the nature of either (1) events like alertConditionChanged and viewDirectionChanged or (2) what a switch/case structure does.Killer Wolf wrote:or maybe i just tried changing some code? pardon me for not being a fkng JS expert.Wildeblood wrote:No, because he has mistaken this.alertConditionChanged for magic.Kaks wrote:Never mind that!
I'm not surprised it's not working, KW's code hasn't got this.viewDirectionChanged anywhere I can see...
Code: Select all
this.viewDirectionChanged = function(viewString)
{
if (viewString == "VIEW_GUI_DISPLAY")
{
player.ship.hud = "phantomGUI.plist";
}
}
Code: Select all
this.alertConditionChanged = function(newCondition, oldCondition)
{
switch(newCondition)
{
case 0: // we're docked
{
player.ship.hud = "phantomTradingHUD.plist"; // set the docked HUD
break;
}
case 1: // we're at green alert
case 2: // or we're at yellow alert
{
if(player.ship.energy > 108 && player.viewString != "VIEW_GUI_DISPLAY") // if we're not using the damaged HUD
{
player.ship.hud = "phantomNormalHUD.plist"; // set the standard HUD
}
break;
}
case 3: // we're at red alert
{
if(player.alertHostiles && player.ship.energy > 108 && player.viewString != "VIEW_GUI_DISPLAY") // and under attack and not using the damaged HUD
{
player.ship.hud = "phantomCombatHUD.plist"; // set the combat HUD
}
break;
}
}
}
new stuff :-
this.viewDirectionChanged = function(viewString)
{
if(player.viewString = "VIEW_GUI_DISPLAY")
{
player.ship.hud = "phantomGUI.plist";
}
else if(player.alertHostiles && player.ship.energy > 108 && player.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";
}
}
end of new stuff
this.shipLaunchedFromStation = function()
{
if(this.energyCheckTimer)
{
this.energyCheckTimer.start()
}
else
{
this.energyCheckTimer = new Timer(this, this.energyCheck,0,2) // use a timer to keep an eye on the HUD state
}
}
this.energyCheck = function()
{
if(player.ship.docked)
{
this.energyCheckTimer.stop();
}
else
{
if(player.ship.energy < 109 )
{
player.ship.hud = "phantomSnafuHUD.plist"; // display the damaged HUD
return;
}
if(player.ship.energy > 108 && player.ship.hud == "phantomSnafuHUD.plist")
{
this.alertConditionChanged(player.alertCondition,0); // if energy is >49 and we're still displaying the damaged HUD, use other code to repair
}
}
}
this.shipDied = function()
{
if(this.energyCheckTimer)
{
this.energyCheckTimer.stop()
}
}
Code: Select all
if(player.viewString = "VIEW_GUI_DISPLAY")
{
player.ship.hud = "phantomGUI.plist";
}
Code: Select all
if(viewString === "VIEW_GUI_DISPLAY")
{
player.ship.hud = "phantomGUI.plist";
}
Code: Select all
this.viewDirectionChanged = function(viewString)
{
if(viewString === "VIEW_GUI_DISPLAY")
{
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";
}
}
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.