Page 2 of 4

Posted: Tue Mar 16, 2010 12:23 pm
by Killer Wolf
cheers A_C, i wasn't sure if one would override the other.

HUD tests

Posted: Sun Mar 28, 2010 11:13 am
by Killer Wolf
Okay, been giving this a test run.

when i dock i change to my trading hud, when i launch i swap to my normal hud - great.

the bit about low energy : it seems very slow to trigger, and once it does it doesn't change back. i thought the script was continually being looked at and the damaged hud would only appear during the low energy state, but i take it i have to add another line saying "if energy > 50 use the normal hud"?

can't get my combat hud to work. the examples quoted previous, i didn't know where to add in the hud statement, so instead i just put

{
if (player.alertHostiles = 1)
{
player.ship.hud = "dbcombathud.plist";
}
}

am i doing that wrong? cos it don't work (just tried putting "== 1" in the test too, cos i spotted a log error which it fixed). i tried shooting a station - cops attacked me, it didn't change. i hyperspaced to Xeesle, attacked a trader who turned red and attacked me, it didn't change. i hyped in on another run, got jumped by a pirate escort, it didn't change :-(

Posted: Sun Mar 28, 2010 1:55 pm
by Thargoid
player.alertHostiles is a boolean (yes/no), so just remove the ==1 completely.

For the Aquatics Guardian system I use something similar:

Code: Select all

if(player.alertCondition == 3 && player.alertHostiles && !missionVariables.aquatics_guardianActive)
Basically alertCondition == 3 means your ship is at red alert and player.alertHostiles being true means that it's got something around that's hostile. Drop the mission variable bit (that's just a check whether the guardians are already active or not) and use something similar.

And yes, once your energy is back up you will need to do something else to change your HUD back again.

Posted: Sun Mar 28, 2010 4:08 pm
by Killer Wolf
Many thanks. i read about it being a Boolean but (being totally JS ignorant) i thought you'd still have to specify if you were looking for a true/false/1/0 off it. i'll give it a retry later.

tell you what though, it might be a fairly minorish cosmetic change, but going from a specific docked hud to an in-flight one upon launching really adds to the game, for me.

ta!

Posted: Tue Mar 30, 2010 6:22 pm
by Killer Wolf
right : bollocks.
can some clever JS person point out my stupidity w/ the following please.

this.shipDockedWithStation = function()
{
player.ship.hud = "dbtradinghud.plist";
}

this.shipWillLaunchFromStation = function(stationLaunchingFrom)
{
player.ship.hud = "dbnormalhud.plist";
}


// The below method has not been tested at all, might as well not compile, shown as quick'n'dirty example
this.shipBeingAttacked = function()
{
if (player.ship.energy < 150)
{
player.ship.hud = "dbsnafuhud.plist";
}
}


this.hudThing = function()
{
if (player.alertCondition == 3)
{
player.ship.hud = "dbcombathud.plist";
}
// else
// {
// player.ship.hud = "dbnormalhud.plist";
// }
}


the stuff down to the energy test was posted here, and works fine. the other stuff i tried to make up, and flatly does not work. it originally didn't have the "this.hudThing" in, then i thought it needed something like that judging by the previous examples. this shows the commented-out Else leg to try and simplify matters, and it still won't play :-(

nowt in the logs saying "hah you suck!" so i'm assuming it's all syntactically ok? and yes, the hud plist names are not typoed.

cheers

Posted: Tue Mar 30, 2010 6:34 pm
by another_commander
Killer Wolf wrote:

Code: Select all

this.hudThing = function()
{
    if (player.alertCondition == 3)
    {
        player.ship.hud = "dbcombathud.plist";
    }
//	else
//	{
//		player.ship.hud = "dbnormalhud.plist";
//	}
}
the stuff down to the energy test was posted here, and works fine. the other stuff i tried to make up, and flatly does not work. it originally didn't have the "this.hudThing" in, then i thought it needed something like that judging by the previous examples. this shows the commented-out Else leg to try and simplify matters, and it still won't play :-(

nowt in the logs saying "hah you suck!" so i'm assuming it's all syntactically ok? and yes, the hud plist names are not typoed.
Well, the this.hudThing is not defined anywhere, this is why it does not run. The other functions (this.shipBeingAttacked, this.shipDockedWithStation etc.) all refer to JS handlers, whose names are defined inside the core game code. As an example, when the player is about to launch, Oolite will try to find if there is a script function referring to the shipWillLaunchFromStation handler and if it finds it, it will execute its contents. Thus, you need to know which handlers are recognizable by Oolite and the wiki contains such a list (can't access it from here atm, so I cannot link to it). In any case, hudThing is not a valid handler. I believe you are looking for the alertConditionChanged one.

Posted: Tue Mar 30, 2010 6:41 pm
by JazHaz
another_commander wrote:
Thus, you need to know which handlers are recognizable by Oolite and the wiki contains such a list (can't access it from here atm, so I cannot link to it).
I think this is the list you are referring to:

http://wiki.alioth.net/index.php/Oolite ... t_handlers

Posted: Tue Mar 30, 2010 6:41 pm
by Thargoid
As A_C ninja'd me (in a role-reversal for him I guess ;) ), I'll just add that the event functions that the game uses are here in the wiki.

As he says, if you replace this.hudThing = function() with this.alertConditionChanged = function() you should see more:

Code: Select all

this.alertConditionChanged = function(newCondition, oldCondition)
{
        if (player.alertCondition == 3 && player.alertHostiles) 
    { 
        player.ship.hud = "dbcombathud.plist"; 
    }
}
I think the newCondition and oldCondition parameters are new (I don't remember them being there last time I looked at the wiki page), so you could probably replace player.alertCondition with newCondition in the if statement.

Editted to add - if you don't put the && player.alertHostiles in you'll get the combat HUD whenever you go to red alert (e.g. if you sunskim). The addition is a logical AND with the property that you're under alert due to hostiles. You can see a full list of the player propertieshere, also in the wiki.

Oh and also to add "damn, double-ninja'd!"

Posted: Wed Mar 31, 2010 6:13 am
by Killer Wolf
oops, stupid me thought it could be a user-defined name to describe a function :-(

cheers all, i'll give that a bash tonight.

Posted: Wed Mar 31, 2010 7:25 am
by Eric Walch
Killer Wolf wrote:
oops, stupid me thought it could be a user-defined name to describe a function :-(

cheers all, i'll give that a bash tonight.
You can define any function name yourself, but someone has to call those functions. The predefined function names are called by Oolite when they exist. Self defined function names have to be called by other parts from your script itself.

Posted: Wed Mar 31, 2010 4:10 pm
by Kaks
In any case I'd definitely put an else with 'normalhud.plist' like

Code: Select all

  else
   {
      player.ship.hud = "dbnormalhud.plist";
   } 
otherwise you get the combat hud with the first hostile(s) - as you want it to do - but then it never reverts back to the original hud once no hostiles are present...

Posted: Wed Mar 31, 2010 4:16 pm
by Killer Wolf
thanks all, i'll be giving that a blast in a mo.

naffing new-fangled javascript - why we can't have PLISTs in COBOL i don't know! :-D

Posted: Wed Mar 31, 2010 4:23 pm
by Cody
Killer Wolf wrote:
why we can't have PLISTs in COBOL i don't know!
Ah, there's a thought... once upon a time I could program in COBOL.

Posted: Wed Mar 31, 2010 6:30 pm
by JazHaz
Can someone make a HUD for Widescreen please?

I run Oolite in 1280 x 800 widescreen! :D

Could be nice to use the full width of the screen, and as widescreen computers are becoming more popular it might be a nice thing to have....

Posted: Wed Mar 31, 2010 7:40 pm
by Killer Wolf
just to officially announce, you guys fkn RULE!!

ah, that's my new ship kitted out, let's launch and have some fun :
Image

ooh, one of those i'm-so-hard Dominatrixes! let's kick her ass!
Image

uh....dammit, this isn't going well!
Image

oh bugger 8-(
Image