Can someone help with HUD ?

Topics regarding Scripting with Reality Factory
Post Reply
User avatar
Gamemaker
Posts: 266
Joined: Fri Aug 08, 2008 3:00 pm
Location: Estonia
Contact:

Can someone help with HUD ?

Post by Gamemaker » Mon May 04, 2009 4:24 pm

Howdy, can anyone help me to make my HUD ? I want that: When I take a gun, then it shows the picture of it...

[beretta_shell]
type = numeric
style = magazine
framex = 100
framey = 560
font = 7
width = 3

[~beretta_shell]
type = numeric
style = ammo
framex = 150
framey = 560
font = 7
width = 3
active = false

[~beretta_shell]
frame = hud\berettahud.bmp
indicatoroffsetx = 150
indicatoroffsety = 180


---- this won't work...---

it shows the picture, but if I change the indicatoroffsety or x, then the numbers come with it.

Metal_head tried to make a script, Zidane too, but nothing helped.


{
Spawn[ ()
{
Console(true);
LowLevel("DoIt");
} ]

DoIt[ ()
{
if (IsKeyDown(3))
{
ShowHudPicture(0, true, "", 10, 10, 3);
}
}]

}

///by metal_head

This works only once, if I hit the key 3.


I need help !!! :)
Thanks,

User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Re: Can someone help with HUD ?

Post by QuestOfDreams » Mon May 04, 2009 5:19 pm

First, you can define only 2 Hud elements for each attribute (you have 3 and the 3rd one doesn't even have a type ...). One named [name] the other one named [~name].
Second, there is no style named ammo (what is it supposed to display?), magazine and clip are the only valid values for style.
If this Hud definition is supposed to be used for a gun, why do you use definitions for ammunition (style)?

User avatar
Gamemaker
Posts: 266
Joined: Fri Aug 08, 2008 3:00 pm
Location: Estonia
Contact:

Re: Can someone help with HUD ?

Post by Gamemaker » Thu May 07, 2009 3:47 pm

It shouldn't be impossible to add a picture of gun in the corner of screen...
don't know, the style = ammo , worked well for me. It showed, how many bullets do I have in the Magazine... :lol:

User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Re: Can someone help with HUD ?

Post by QuestOfDreams » Thu May 07, 2009 5:55 pm

You need to be more specific about what you want to do, otherwise I have to guess and probably won't be able to help you.
Usually you have an attribute defined for the ammunition (e.g. bullet) and an attribute defined for the gun (e.g. gun)
The Hud definition for the ammunition could look like this:

Code: Select all

[bullet]
type = numeric
style = magazine
framex = -100
framey = 0
indicatoroffsetx = 36
indicatoroffsety = 138
font = 7
width = 3
active = false 

[~bullet]
type = numeric
style = clip
framex = -100
framey = 0
indicatoroffsetx = 36
indicatoroffsety = 158
font = 7
width = 3
active = false
This will display the number of bullets left in the current clip and the number of clips (if a weapon that uses the bullets is active).

The Hud definition for the gun could be

Code: Select all

[gun]
type = numeric
frame = gunhud.bmp
framealpha = a_gunhud.bmp
framex = -100
framey = 0
indicatoroffsetx = 36
indicatoroffsety = 38
font = 7
width = 3 
active = modify
modifydirection = up
displaytime = 5
This will display a frame bitmap (that could show a gun) and the number of guns for 5 seconds each time you pick up a gun attribute.

Tinned Bread
Posts: 3
Joined: Sun Oct 21, 2012 11:47 pm

Re: Ammo clips on HUD "Stacking"

Post by Tinned Bread » Mon Oct 22, 2012 12:40 am

I'm having a slight problem with the ammo clip display. I have followed your example, looked in the e-book and also looked at the manual; however, I cannot find a solution.

After following your example and previewing the game I'm making, it displays the magazine size and how many clips I have left; so that's fine. But, when I made versions of this code to suit the other ammunition types, I hit a problem; it still displays the magazine size for each individual weapon: no problem there. But the amount of clips left all show at once, so the amount of clips for the pistol, shotgun, sniper etc. all show at the same time, on the same spot.

This problem only goes away once I have switched to each weapon at least once or when I only use this code for one weapon. Is there any way around this?

I'm new to the forums so if I need to post any extra information, let me know.

Thanks! :)

EDIT: It keeps showing an extra "100" where the amount if clips should be, and it doesn't go away until I have equipped each weapon at least once. I'm guessing the "100" is from the player.ini, where it displays the initial ammunition amount.

Going to make the initial ammunition set to "0", then put some ammo crates in-game near the character. Hopefully that works.

UPDATE: It is definitely the initial amount of ammo in the player.ini file that keeps being displayed, as I changed them all to "0" (Which resulted in no ammo, magazines or clips, so it displayed both of these as "0" on-screen). Once changed, it showed both magazine and ammo count at "0", as it should. As the initial ammunition is now set to "0", it has merged into the clip amount section. Is there anyway to prevent the initial ammunition count from the player.ini from showing?
Last edited by Tinned Bread on Mon Oct 22, 2012 3:40 pm, edited 1 time in total.

Tinned Bread
Posts: 3
Joined: Sun Oct 21, 2012 11:47 pm

Partial solution to the "initial" ammunition display

Post by Tinned Bread » Mon Oct 22, 2012 2:17 pm

I have found a partial solution to the "initial" ammunition being displayed on the in-game HUD. This solution stops this from happening for all weapons, except for the Sprayer (Flamethrower).

For the HUD to display the magazine size and how many clips were left, I followed the above example for all ammunition types and got this result:

Code: Select all

[pistol_shell]
type = numeric
style = magazine
framex = 10
framey = 10
indicatoroffsetx = 36
indicatoroffsety = 520
font = 7
width = 3
active = false


[~pistol_shell]
type = numeric
style = clip
framex = 10
framey = 10
indicatoroffsetx = 36
indicatoroffsety = 540
font = 7
width = 3
active = false

[GL_Grenade]
type = numeric
style = magazine
framex = 10
framey = 10
indicatoroffsetx = 36
indicatoroffsety = 520
font = 7
width = 3
active = false

[~GL_Grenade]
type = numeric
style = clip
framex = 10
framey = 10
indicatoroffsetx = 36
indicatoroffsety = 540
font = 7
width = 3
active = false

[disk]
type = numeric
style = magazine
framex = 10
framey = 10
indicatoroffsetx = 36
indicatoroffsety = 520
font = 7
width = 3
active = false

[~disk]
type = numeric
style = clip
framex = 10
framey = 10
indicatoroffsetx = 36
indicatoroffsety = 540
font = 7
width = 3
active = false


[rifle_shell]
type = numeric
style = magazine
framex = 10
framey = 10
indicatoroffsetx = 36
indicatoroffsety = 520
font = 7
width = 3
active = false

[~rifle_shell]
type = numeric
style = clip
framex = 10
framey = 10
indicatoroffsetx = 36
indicatoroffsety = 540
font = 7
width = 3
active = false

[10mm_shell]
type = numeric
style = magazine
framex = 10
framey = 10
indicatoroffsetx = 36
indicatoroffsety = 520
font = 7
width = 3
active = false

[~10mm_shell]
type = numeric
style = clip
framex = 10
framey = 10
indicatoroffsetx = 36
indicatoroffsety = 540
font = 7
width = 3
active = false

[shotgun_shell]
type = numeric
style = magazine
framex = 10
framey = 10
indicatoroffsetx = 36
indicatoroffsety = 520
font = 7
width = 3
active = false

[~shotgun_shell]
type = numeric
style = clip
framex = 10
framey = 10
indicatoroffsetx = 36
indicatoroffsety = 540
font = 7
width = 3
active = false
You'll notice that the Sprayer (Flamethrower) isn't on there, more on that later.

After reading through the manual again, I re-read the section that teaches you how to make this HUD, and it mentions adding an "active = false" statement to prevent it all showing up at once. So, after trying and having no success, I decided to see if it has an effect in the "player.ini" document. Success. The added statement looked like the following:

Code: Select all

[pistol_shell]
initial = 65
low = 0
high = 130
active = false

[shotgun_shell]
initial = 40
low = 0
high = 100
active = false

(I've added the statement to each ammunition type)

However, the issue was still happening, so I decided to pin-point the exact problem. It turned out to be the Sprayer (Flamethrower). After deleting it's ammunition magazine and clip display, the issue went away. So, all in all, this solution works for all weapons except for the Sprayer (Flamethrower). I have a feeling that it could be the ammunition type, as it doesn't use bullets? I'll be experimenting, if I find a solution for the Sprayer (Flamethrower), I'll post it here. :D

Anyways, I hope this helps someone. :)

EDIT: I have found the solution to the Sprayer (Flamethrower) problem.

After adding the Sprayer (Flamethrower) version of the code to the "hud.ini" file:

Code: Select all

[ball]
type = numeric
style = magazine
framex = 10
framey = 10
indicatoroffsetx = 36
indicatoroffsety = 520
font = 7
width = 3
active = false

[~ball]
type = numeric
style = clip
framex = 10
framey = 10
indicatoroffsetx = 36
indicatoroffsety = 540
font = 7
width = 3
active = false



Just make sure that you leave a few blank lines at the end. So after the last "active = false" just press enter a few times to create some blank lines, like I've done in the example above. :)

It was a minor problem that I'm now face planting myself over! :D

Enjoy. :)

NOTE: Just to make it easier for others to find, I'll add some keywords that will help with their search.

Tags: how , to , hud , ammo , ammunition , help , solution , working , heads , up , display , player.ini , hud.ini

Post Reply