Scripts / Text formats in lua?

Author
Message
OldFlak
GameGuru TGC Backer
9
Years of Service
User Offline
Joined: 27th Jan 2015
Location: Tasmania Australia
Posted: 16th Oct 2016 22:57 Edited at: 16th Oct 2016 23:02
Hi all,

I am playing around with making a custom HUD, and am having issues with displaying text for health, ammo etc.

Can someone point me to a lua guide that shows the formatting for displaying variables in text?

And also how can I reference the current weapons image\icons to display on screen...

Thanks in advance

Reliquia....
Intel(R) Core(TM) i3-4160 @ 3,60GHz. 8GB Ram. NVidia GeForce GTX 750. Acer 24" Monitors x 2 @ 1920 x 1080. Windows 10 Pro 64-bit.
PM
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 16th Oct 2016 23:22 Edited at: 16th Oct 2016 23:23
Text(X position %,Y position %,text size 1 to 7,"actual text") ----- puts your text starting at the X Y coordinates and in the size you specify

TextCenterOnX(X position %,Y position %,text size 1 to 7,"actual text") -----puts your text cantered at the X Y coordinates and in the size you specify

TextColor(X position %,Y position %,text size 1 to 7,"actual text",red,green,blue) ----- puts your text starting at the X Y coordinates and in the size you specify in the colors specified at the end (ie pure red would be 250,0,0 etc.

TextCenterOnXColor(X position %,Y position %,text size 1 to 7,"actual text",red,green,blue) ----- puts your text cantered at the X Y coordinates and in the size you specify in the colors specified at the end (ie pure red would be 250,0,0 etc.

Sorry, I don't know about weapon icons.

i5, NV960 2GB, 16GB memory, 2x 2TB Hybrid, Win10.
i3 , Intel integrated graphics, 6GB memory, 512GB Generic SATAIII Win8.1.
Intel Celeron (duel Core), Radeon integrated graphics, 4GB memory, 180gB Generic SATAII, WinVista.
Q6600, Intel integrated graphics, 8GB memory, 512GB Generic SATAII, Win7.
OldFlak
GameGuru TGC Backer
9
Years of Service
User Offline
Joined: 27th Jan 2015
Location: Tasmania Australia
Posted: 17th Oct 2016 03:04
@Belidos, thanks for the info. The positioning of text as outlined above is Ok - I have that all working great - thanks.

The issue I am having is correct formatting for displaying values as text.

For example:

This displays the values for Health and Lives:


However these two lines throw errors:


Also I think maybe I should be casting the values some how before using them as text....

Reliquia....
Intel(R) Core(TM) i3-4160 @ 3,60GHz. 8GB Ram. NVidia GeForce GTX 750. Acer 24" Monitors x 2 @ 1920 x 1080. Windows 10 Pro 64-bit.
PM
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 17th Oct 2016 06:09 Edited at: 17th Oct 2016 08:10
You have to tell it you variable is a variable by prefixing it with ..

Text(x,y,size,"text"..variable)

Text(x,y,size,"text"..variable,r,g,b)

That should do it ...


I'll double check sand elaborate when i get into work, can't at the moment as I'm using my phone.

i5, NV960 2GB, 16GB memory, 2x 2TB Hybrid, Win10.
i3 , Intel integrated graphics, 6GB memory, 512GB Generic SATAIII Win8.1.
Intel Celeron (duel Core), Radeon integrated graphics, 4GB memory, 180gB Generic SATAII, WinVista.
Q6600, Intel integrated graphics, 8GB memory, 512GB Generic SATAII, Win7.
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 17th Oct 2016 06:09 Edited at: 17th Oct 2016 06:10
Daft phone double posted lol

i5, NV960 2GB, 16GB memory, 2x 2TB Hybrid, Win10.
i3 , Intel integrated graphics, 6GB memory, 512GB Generic SATAIII Win8.1.
Intel Celeron (duel Core), Radeon integrated graphics, 4GB memory, 180gB Generic SATAII, WinVista.
Q6600, Intel integrated graphics, 8GB memory, 512GB Generic SATAII, Win7.
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 17th Oct 2016 08:07 Edited at: 17th Oct 2016 16:29
OK, here we go....

To display player health:

The current health variable is g_PlayerHealth, to display the maximum/starting health you need to convert it from a gameloop variable to a variable that can be read in the script, so you would add g_max_PlayerHealth = g_gameloop_StartHealth and use g_max_PlayerHealth as your variable.



To display ammo:

The variable for your current ammo count is g_PlayerGunAmmoCount, and the variable for your clip count is g_PlayerGunClipCount.



To display lives:

The variable for lives is g_PlayerLives



I'm fairly sure that's right, at least i'm sure that's how i've used it in my hud script.

i5, NV960 2GB, 16GB memory, 2x 2TB Hybrid, Win10.
i3 , Intel integrated graphics, 6GB memory, 512GB Generic SATAIII Win8.1.
Intel Celeron (duel Core), Radeon integrated graphics, 4GB memory, 180gB Generic SATAII, WinVista.
Q6600, Intel integrated graphics, 8GB memory, 512GB Generic SATAII, Win7.
OldFlak
GameGuru TGC Backer
9
Years of Service
User Offline
Joined: 27th Jan 2015
Location: Tasmania Australia
Posted: 18th Oct 2016 15:38
@Belidos, thanks for your help. Much appreciated!

Just have to work out how to reference the current weapon, but the text is all under control. Thanks again!

Reliquia....
Intel(R) Core(TM) i3-4160 @ 3,60GHz. 8GB Ram. NVidia GeForce GTX 750. Acer 24" Monitors x 2 @ 1920 x 1080. Windows 10 Pro 64-bit.
PM
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 18th Oct 2016 15:52
You're welcome, sorry i can't help with the weapon stuff, i've been wondering how to do that myself.

i5, NV960 2GB, 16GB memory, 2x 2TB Hybrid, Win10.
i3 , Intel integrated graphics, 6GB memory, 512GB Generic SATAIII Win8.1.
Intel Celeron (duel Core), Radeon integrated graphics, 4GB memory, 180gB Generic SATAII, WinVista.
Q6600, Intel integrated graphics, 8GB memory, 512GB Generic SATAII, Win7.
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 18th Oct 2016 18:15 Edited at: 18th Oct 2016 18:16
g_PlayerGunName = ""
gets the full name of the currently held gun but it will also include any sub folders
use it like
Prompt("current gun = "..g_PlayerGunName)
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11

Login to post a reply

Server time is: 2024-12-22 23:06:03
Your offset time is: 2024-12-22 23:06:03