Scripts / Updating the default HUD

Author
Message
gilmaxter
8
Years of Service
User Offline
Joined: 9th Feb 2016
Location:
Posted: 9th Feb 2016 02:27
Hello and greetings all

Now my question lies in the default hud script. Is it possible to change it ? I want to make a bar for running / sprinting for the shift so that you can't abuse it. But I do not know where to start for that. Can it be possible to make global variables on this engine or is that not possible because I want to make my own variables and display that on the hud but do not know if that is possible. Where would I go for a hud tutorial for game guru. Some odd questions but hopefully I can get some response here thank you very much have a good day.
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 9th Feb 2016 10:58 Edited at: 9th Feb 2016 11:00
This will restrict the sprint https://forum.game-guru.com/outbound?url=https%3A%2F%2Fforum.game-guru.com%2Fthread%2F207801%3Fpage%3D12%23msg2538382
And then use
Panel(x1,y1,x2,y2)
TextX(x,y,size,string)
To make a basic HUD
Or better use a sprite.

P.s. you can see an example of a percentage based bar using text in my thread too (although I used it for health)
https://forum.game-guru.com/outbound?url=https%3A%2F%2Fforum.game-guru.com%2Fthread%2F207801%3Fpage%3D9%23msg2524790
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11
gilmaxter
8
Years of Service
User Offline
Joined: 9th Feb 2016
Location:
Posted: 10th Feb 2016 00:49
So then on the global.lua I would do this for example

function Panel(x,y,x2,y2)
SendMessageF("panelx",x);
SendMessageF("panely",y);
SendMessageF("panelx2",x2);
SendMessageF("panely2",y2);
TextX(x,y,3,"Testing the HUD")
end

and that would show the the text ?
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 10th Feb 2016 11:49
no, do not change the global for anything other than storing functions and initial variables (and even then you should probably do that in the script per map)

you would change
Quote: "Prompt("sprint % = "..sprint_perc)"

from the sprint script to your own HUD using the Text and Panel commands (you do not need the other stuff like sendmessage)

as a basic example change it to this
Panel(35,85,65,95)
TextCenterOnX(50,87,3,"sprint % = "..sprint_perc)
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11
gilmaxter
8
Years of Service
User Offline
Joined: 9th Feb 2016
Location:
Posted: 24th Feb 2016 03:14
Okay

don't know if I should start another thread for this.

I want to make a new variable. anxiety for example.

I would put it in global.lua

now what I want is to make a script that would increase the anxiety by 1 every 5 minutes or something in the game.

can I use the wait (30000000) command like in java or C# . or do I have to use something else ? and can I get that variable in display similar to the sprint example and just change the points on the grid since that is what It seems to be on the panel. thank you.
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 24th Feb 2016 09:15 Edited at: 24th Feb 2016 09:22
You need to use StartTimer(e) and GetTimer(e)

Also you can apply variables to scripts themselves (even if they are global), best not to adjust the global.lua as updates will restore it and remove your variables.

So your script will look like this
Save it as fear.lua and assign it to an always active object (p.s. sorry if there's any mistakes, written from my phone so obviously it's untested but its a simple script, should work fine unless there's any small spelling errors)
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11
gilmaxter
8
Years of Service
User Offline
Joined: 9th Feb 2016
Location:
Posted: 25th Feb 2016 00:25
yes, sweet thank you

Yes what I was planning is can I use a spawn enemy function with this as well to where when the anxiety gets past 10,20,30,etc a enemy will spawn behind the player.
PM
gilmaxter
8
Years of Service
User Offline
Joined: 9th Feb 2016
Location:
Posted: 25th Feb 2016 22:18
Update: I seem to be getting a syntax error saying:

Syntax error near GetTimer line 7 here is the code so far.


Anxiety = 0
function fear_init(e)
end


function fear_main(e)
If GetTimer(e) > 300000 then
StartTimer(e)
Anxiety = Anxiety + 1
end

If Anxiety > 99 then
--HurtPlayer(e,g_PlayerHealth)
--Show('ClownZombie') -- Not working for some reason.
Anxiety = 0
end

Panel(35,1,65,5)
TextCenterOnX(50,3,3,"Anxiety = "..Anxiety.." %")
end
end
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 25th Feb 2016 23:11
its because my phone auto capitalises everything and lua doesnt like capitals (and also i added an extra end)
here's a working script
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11
gilmaxter
8
Years of Service
User Offline
Joined: 9th Feb 2016
Location:
Posted: 25th Feb 2016 23:35 Edited at: 26th Feb 2016 00:28
I am seeing the anxiety ticking away fine.

and the zombie clown is now popping up.

how does the entity index work from the top of the list down does the first item on the list start as 1 or 0 ?


PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 26th Feb 2016 00:27
place the zombie clown in the map and set it to spawn at start = no and remove his script, then hover the mouse of him and you will find the entity number at the bottom of the screen in the status bar.

the above script should be set to another object that is set always active = yes
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11
gilmaxter
8
Years of Service
User Offline
Joined: 9th Feb 2016
Location:
Posted: 26th Feb 2016 00:30
Got it thank you

PM

Login to post a reply

Server time is: 2024-05-03 14:08:42
Your offset time is: 2024-05-03 14:08:42