Scripts / [SOLVED] How to show a HUD Script for anywhere in the game

Author
Message
Garry68
4
Years of Service
User Offline
Joined: 8th Aug 2020
Location:
Posted: 8th Aug 2020 21:08
I made a simple HUD script to replace the default one, but don't know where to add it so it shows wherever you are in the level/game.

The script itself works fine if I attach it to an object at the start of the level, but as soon as I move out of range of the object the script stops and disappears. The LUA itself is quite simple (see below)

So, is there a 'global' object I can attach this to, so it shows everywhere on the level, or do I need to place it in a particular initiation script?


Any help would be appreciated.


LUA:
function custommarshud_init(e)
HideHuds()
CO2 = 102
O2 = 0
end

function custommarshud_main(e)

Panel(1,1,20,17)
Text(3,2,6,"Health")
Text(3,7,6,"CO2")
Text(3,11,6,"O2")
Text(11,2,6,": "..math.floor(g_PlayerHealth).."%")
Text(11,7,6,": "..math.floor(CO2).."%")
Text(11,11,6,": "..math.floor(O2).."%")

if CO2 >= 0 then
CO2 = CO2 - .005
else
HurtPlayer(e,g_PlayerHealth)
CO2 = 100
O2 = 0
end

if math.floor(g_PlayerHealth) <= 90 then
O2 = O2 + .015
if O2 >= 100 then
HurtPlayer(e,g_PlayerHealth)
CO2 = 100
O2 = 0
end
end
end

The author of this post has marked a post as an answer.

Go to answer
PM
Garry68
4
Years of Service
User Offline
Joined: 8th Aug 2020
Location:
Posted: 9th Aug 2020 02:01
So, I updated my script to this to try and move the object (a Trigger Zone) with the player coordinates, but it didn't work. Any idea why?

function custommarshud_init(e)
HideHuds()
CO2 = 102
O2 = 0
end

function custommarshud_main(e)

Panel(1,1,20,17)
Text(3,2,6,"Health")
Text(3,7,6,"CO2")
Text(3,11,6,"O2")
Text(11,2,6,": "..math.floor(g_PlayerHealth).."%")
Text(11,7,6,": "..math.floor(CO2).."%")
Text(11,11,6,": "..math.floor(O2).."%")

if CO2 >= 0 then
CO2 = CO2 - .005
else
HurtPlayer(e,g_PlayerHealth)
CO2 = 100
O2 = 0
end

if math.floor(g_PlayerHealth) <= 90 then
O2 = O2 + .015
if O2 >= 100 then
HurtPlayer(e,g_PlayerHealth)
CO2 = 100
O2 = 0
end
end

g_Entity[e]['x'] = g_PlayerPosX
g_Entity[e]['y'] = g_PlayerPosY
g_Entity[e]['z'] = g_PlayerPosZ
SetPosition(e,g_Entity[e]['x'],g_Entity[e]['y'],g_Entity[e]['z'])
end
PM
bluemeenie195
6
Years of Service
User Offline
Joined: 28th Oct 2018
Location:
Posted: 9th Aug 2020 02:25
This post has been marked by the post author as the answer.
Make the object you applied the script to always active.
PM

Login to post a reply

Server time is: 2024-12-22 03:01:39
Your offset time is: 2024-12-22 03:01:39