Page 1 of 2
Special Hud thing
Posted: Wed Sep 30, 2009 4:07 am
by GMer
In my game I need a feature where a variable appears on the HUD, that keeps increasing over time. By pressing space (key map # 46 I think) you can decrease the variable. At a certain point if the variable isn't below a certain value, it plays one movie (and game over, consequently), if it is below the value, the game plays a different movie and continues the game. How can I do this?
Re: Special Hud thing
Posted: Wed Sep 30, 2009 3:27 pm
by metal_head
Alright, for this to work you'll need a timer.
Add a variable, called "INCREASETIMER" and a variable, called "TIMERAMOUNT"
Than in the script:
Code: Select all
if(INCREASETIMER < self.time)
{
if (IsKeyDown(46))
{
ModifyAttribute("name", 5, char "Player");
}
else
{
ModifyAttribute("name", -5, char "Player");
}
INCREASETIMER = self.time + TIMERAMOUNT;
} ]
Get it? In the TIMERAMOUNT variable you put the ammount of pause time. You check than if the Space button is pressed and modify the attribute, called "name" with +5, but if space is not pressed (else), the attribute "name" decreases

Re: Special Hud thing
Posted: Thu Oct 01, 2009 4:01 am
by GMer
Allright! I do get how the script works (that's a good thing), but I put assign this to a pawn, add the variable "speed" into player.ini and the attribute.txt, and assign it accordingly in the script (and add a numeric hud thingy into hud.ini), but the attribute won't change.
Re: Special Hud thing
Posted: Thu Oct 01, 2009 2:39 pm
by metal_head
Put a
Code: Select all
debug(GetAttribute("name", "Player");
after the timer thing and see if it changes. If it changes, than it's your HUD description, if not, than paste the script here, I'll check it out

Re: Special Hud thing
Posted: Thu Oct 01, 2009 10:39 pm
by GMer
Won't work oddly, here is the code:
Code: Select all
{
TIMERAMOUT [1]
Spawn[()
Console(true);
NewOrder(Keycheck);
]
Keycheck[()
if(INCREASETIMER < self.time)
{
if (IsKeyDown(46))
{
ModifyAttribute("speed", 5, char "Player");
}
else
{
ModifyAttribute("speed", -5, char "Player");
}
INCREASETIMER = self.time + TIMERAMOUNT;
}
debug(GetAttribute("speed", "Player");
RestartOrder()
]
}
Re: Special Hud thing
Posted: Fri Oct 02, 2009 4:51 am
by darksmaster923
You have
ModifyAttribute("speed", -5, char "Player");
Take out char.
so it would be
ModifyAttribute("speed", -5, "Player");
Re: Special Hud thing
Posted: Fri Oct 02, 2009 9:44 am
by Juutis
... and:
NewOrder("Keycheck");
Re: Special Hud thing
Posted: Mon Oct 05, 2009 8:39 am
by metal_head
ModifyAttribute("speed", -5, char "Player");
Oh, my bad

I usually copy the commands from the manual and replace the parameter descriptions, cuz I can't remember them, and I haven't deleted the "char" before the EntityName

Re: Special Hud thing
Posted: Mon Oct 05, 2009 10:32 pm
by GMer
Still won't work... the console won't show up, too. But just in case, here's the code:
Code: Select all
{
TIMERAMOUT [1]
Spawn[ ()
{
Console(true);
NewOrder(Keycheck);
}]
Keycheck[ ()
{
if(INCREASETIMER < self.time)
{
if (IsKeyDown(46))
{
ModifyAttribute("speed", 5,"Player");
}
else
{
ModifyAttribute("speed", -5,"Player");
}
INCREASETIMER = self.time + TIMERAMOUNT;
}
debug(GetAttribute("speed", "Player");
RestartOrder()
}]
}
Here is my hud.ini "speed" entry
Code: Select all
[speed]
type = horizontal
frame = hud\hud_health_oxygen.bmp
framealpha = hud\a_hud_oxygen.bmp
indicator = hud\hud_health_oxygeni.bmp
indicatoralpha = hud\a_hud_oxygeni.bmp
framex = 10
framey = 10
indicatoroffsetx = 25
indicatoroffsety = 0
indicatorwidth = 160
flipindicator = true
active = true
[~speed]
type = numeric
framex = 10
framey = 10
indicatoroffsetx = 202
indicatoroffsety = 30
font = 7
width = 16
active = true
The player.ini "speed" entry
Code: Select all
; speed
[speed]
initial = 10
low = 0
high = 100
And the attributes.txt "speed" entry
Re: Special Hud thing
Posted: Tue Oct 06, 2009 7:11 pm
by metal_head
Try removing this

Re: Special Hud thing
Posted: Tue Oct 06, 2009 11:49 pm
by GMer
Just tried it. Still won't work
I guess the ghost in my computer is acting up again

Re: Special Hud thing
Posted: Wed Oct 07, 2009 3:16 am
by darksmaster923
If the console doesn't show up, then you're missing some important syntax but I can't find it
Re: Special Hud thing
Posted: Wed Oct 07, 2009 1:48 pm
by Jay
Try
Code: Select all
{
TIMERAMOUT [1.0]
Spawn[ ()
{
Console(true);
LowLevel("Keycheck");
} ]
Keycheck[ ()
{
if(INCREASETIMER < self.time)
{
if (IsKeyDown(46))
{
ModifyAttribute("speed", 5,"Player");
}
else
{
ModifyAttribute("speed", -5,"Player");
}
INCREASETIMER = self.time + StringCopy(TIMERAMOUNT);
}
debug(GetAttribute("speed", "Player"));
} ]
}
The second order must be in LowLevel, or it will not be executed every frame, and it could become very inaccurate in its time measurements.
And also check if the StartOrder of the Pawn is 'Spawn'.
Also, in the Realityfactory.log is there a part where it says: 'Reader Script error'... (Just search inside the document)?
Re: Special Hud thing
Posted: Wed Oct 07, 2009 3:52 pm
by metal_head
I was checking for syntax mistakes, but didn't see that in the KeyCheck order there's a NewOrder() command, not LowLevel(). Anyway, now I can't see a reason why the script won't work

Re: Special Hud thing
Posted: Wed Oct 07, 2009 10:46 pm
by GMer
Console shows up (it would help if I assigned the right script to it

) and I get this message:
Code: Select all
Pawn2 Spawn NewOrder
:12: Parse error near "" *
What is that about?