Special Hud thing

Topics regarding Scripting with Reality Factory
User avatar
GMer
Posts: 329
Joined: Thu Oct 25, 2007 4:49 pm
Location: On the rock in the 3rd solar orbit.

Special Hud thing

Post by GMer » Wed Sep 30, 2009 4:07 am

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?
Over 3 years (has it been that long?) and just now I noticed the day and month of my birthday were switched. Whoops!

Some 2d games I made, haven't made anything in a year though O.o
http://www.yoyogames.com/users/GMer56

User avatar
metal_head
Posts: 1244
Joined: Sat Jan 05, 2008 8:31 pm
Location: Bulgaria,Sofia
Contact:

Re: Special Hud thing

Post by metal_head » Wed Sep 30, 2009 3:27 pm

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 :)

User avatar
GMer
Posts: 329
Joined: Thu Oct 25, 2007 4:49 pm
Location: On the rock in the 3rd solar orbit.

Re: Special Hud thing

Post by GMer » Thu Oct 01, 2009 4:01 am

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.
Over 3 years (has it been that long?) and just now I noticed the day and month of my birthday were switched. Whoops!

Some 2d games I made, haven't made anything in a year though O.o
http://www.yoyogames.com/users/GMer56

User avatar
metal_head
Posts: 1244
Joined: Sat Jan 05, 2008 8:31 pm
Location: Bulgaria,Sofia
Contact:

Re: Special Hud thing

Post by metal_head » Thu Oct 01, 2009 2:39 pm

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 :)

User avatar
GMer
Posts: 329
Joined: Thu Oct 25, 2007 4:49 pm
Location: On the rock in the 3rd solar orbit.

Re: Special Hud thing

Post by GMer » Thu Oct 01, 2009 10:39 pm

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() 
	]
}
Over 3 years (has it been that long?) and just now I noticed the day and month of my birthday were switched. Whoops!

Some 2d games I made, haven't made anything in a year though O.o
http://www.yoyogames.com/users/GMer56

User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA
Contact:

Re: Special Hud thing

Post by darksmaster923 » Fri Oct 02, 2009 4:51 am

You have
ModifyAttribute("speed", -5, char "Player");

Take out char.

so it would be

ModifyAttribute("speed", -5, "Player");
Herp derp.

User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Re: Special Hud thing

Post by Juutis » Fri Oct 02, 2009 9:44 am

... and:
NewOrder("Keycheck");
Pain is only psychological.

User avatar
metal_head
Posts: 1244
Joined: Sat Jan 05, 2008 8:31 pm
Location: Bulgaria,Sofia
Contact:

Re: Special Hud thing

Post by metal_head » Mon Oct 05, 2009 8:39 am

ModifyAttribute("speed", -5, char "Player");
Oh, my bad :oops: 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 :)

User avatar
GMer
Posts: 329
Joined: Thu Oct 25, 2007 4:49 pm
Location: On the rock in the 3rd solar orbit.

Re: Special Hud thing

Post by GMer » Mon Oct 05, 2009 10:32 pm

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

Code: Select all

speed
10
0
100
Over 3 years (has it been that long?) and just now I noticed the day and month of my birthday were switched. Whoops!

Some 2d games I made, haven't made anything in a year though O.o
http://www.yoyogames.com/users/GMer56

User avatar
metal_head
Posts: 1244
Joined: Sat Jan 05, 2008 8:31 pm
Location: Bulgaria,Sofia
Contact:

Re: Special Hud thing

Post by metal_head » Tue Oct 06, 2009 7:11 pm

Code: Select all

RestartOrder()
Try removing this :)

User avatar
GMer
Posts: 329
Joined: Thu Oct 25, 2007 4:49 pm
Location: On the rock in the 3rd solar orbit.

Re: Special Hud thing

Post by GMer » Tue Oct 06, 2009 11:49 pm

Just tried it. Still won't work :(
I guess the ghost in my computer is acting up again :P
Over 3 years (has it been that long?) and just now I noticed the day and month of my birthday were switched. Whoops!

Some 2d games I made, haven't made anything in a year though O.o
http://www.yoyogames.com/users/GMer56

User avatar
darksmaster923
Posts: 1857
Joined: Wed Jan 03, 2007 10:32 pm
Location: Huntington Beach, California, USA
Contact:

Re: Special Hud thing

Post by darksmaster923 » Wed Oct 07, 2009 3:16 am

If the console doesn't show up, then you're missing some important syntax but I can't find it
Herp derp.

Jay
RF Dev Team
Posts: 1232
Joined: Fri Jul 08, 2005 1:56 pm
Location: Germany

Re: Special Hud thing

Post by Jay » Wed Oct 07, 2009 1:48 pm

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)?
Everyone can see the difficult, but only the wise can see the simple.
-----

User avatar
metal_head
Posts: 1244
Joined: Sat Jan 05, 2008 8:31 pm
Location: Bulgaria,Sofia
Contact:

Re: Special Hud thing

Post by metal_head » Wed Oct 07, 2009 3:52 pm

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 :)

User avatar
GMer
Posts: 329
Joined: Thu Oct 25, 2007 4:49 pm
Location: On the rock in the 3rd solar orbit.

Re: Special Hud thing

Post by GMer » Wed Oct 07, 2009 10:46 pm

Console shows up (it would help if I assigned the right script to it :P ) and I get this message:

Code: Select all

Pawn2 Spawn NewOrder
:12: Parse error near "" *
What is that about?
Over 3 years (has it been that long?) and just now I noticed the day and month of my birthday were switched. Whoops!

Some 2d games I made, haven't made anything in a year though O.o
http://www.yoyogames.com/users/GMer56

Post Reply