Scripts / Custom hud help

Author
Message
absurd
4
Years of Service
User Offline
Joined: 11th Feb 2020
Location:
Posted: 28th Feb 2020 15:39
i'm trying to make a custom hud. everytime i try and load an image i keep getting runtime errors. i'm not sure what i'm doing wrong? but i'm trying to get a blank white t-shirt (100 health) and everytime i get shot or something, it gets bloodier and bloodier (75%-45%-25%-5%etc) and everytime i heal, the white t shirt gets whiter. also have room for ammo counter on the side and more stuff around the screen if needed. sorry if this is a repeat forum thread but i cant figure it out. thanks guys.
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 28th Feb 2020 16:06
Crystal ball is a bit cloudy today so could you post the script maybe?
Been there, done that, got all the T-Shirts!
PM
absurd
4
Years of Service
User Offline
Joined: 11th Feb 2020
Location:
Posted: 28th Feb 2020 21:57
i've tried both of these trying to put images in the hud. can't seem to figure out the coding
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 29th Feb 2020 09:46
Both of what? Looks like you missed some details there
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
absurd
4
Years of Service
User Offline
Joined: 11th Feb 2020
Location:
Posted: 29th Feb 2020 15:46
--[[This is what goes inside of a dynamic always active entity.--]]

g_player_current_hp = g_PlayerHealth

-------------------- HUD Locations and Sizes --------------------

-- Ammo --
--text location
local lives_tex_posx = 6
local lives_tex_posy = 91.5
local lives_text_size = 20
--sprite location
local lives_spr_posx = 1
local lives_spr_posy = 91
--sprite size
local lives_spr_sizex = 10
local lives_spr_sizey = 5




function lives_hud_init(e)

HideHuds()

-------------------- HUD ICONS --------------------


-- Ammo --
lives_sprite = LoadImage("scriptbank\\images\\lives.png")
lives_icon = CreateSprite(lives_sprite)
SetSpriteSize (lives_icon,lives_spr_sizex,lives_spr_sizey)
SetSpriteDepth (lives_sprite, 100)
SetSpritePosition(lives_icon,300,300)




end

function lives_hud_main(e)


-------------------- Ammo --------------------

PasteSpritePosition(lives_icon,lives_spr_posx,lives_spr_posy)
TextCenterOnX(lives_tex_posx,lives_tex_posy,4,""..g_PlayerLives)




end
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 29th Feb 2020 16:39 Edited at: 29th Feb 2020 16:39
SetSpriteDepth (lives_sprite, 100) <-- should be lives_icon not lives_sprite

You can do this btw:

local lives_icon = CreateSprite( LoadImage( "scriptbank\\images\\lives.png" ) )
SetSpriteSize ( lives_icon, lives_spr_sizex, lives_spr_sizey )
SetSpriteDepth ( lives_icon, 100 )
SetSpritePosition( lives_icon,300,300 )

function lives_hud_init( e )
HideHuds()
end
function lives_hud_main( e )
-------------------- Ammo --------------------
PasteSpritePosition( lives_icon, lives_spr_posx, lives_spr_posy )
TextCenterOnX( lives_tex_posx, lives_tex_posy, 4, "" .. g_PlayerLives )
end
Been there, done that, got all the T-Shirts!
PM
absurd
4
Years of Service
User Offline
Joined: 11th Feb 2020
Location:
Posted: 1st Mar 2020 06:42
i keep getting a runtime error. i just copied and pasted that code.
PM
absurd
4
Years of Service
User Offline
Joined: 11th Feb 2020
Location:
Posted: 1st Mar 2020 06:51

i've also seen this on youtube but i dont know how i can add my own images (the t shirt) into the hud wihtout runtime errors.

-- LUA Script - by Dvader
-- Custom HUD


function custom_hud_init(e)
HideHuds()
HUD=0
keycheck=0
respawned=0
cursor_im=LoadImage ( "scriptbank\\images\\healthbar\\health.png" )
end

function custom_hud_main(e)
PlayerDist = GetPlayerDistance(e)

if respawned==0 then
respawned=1
initialhealth=g_PlayerHealth
end


if g_Scancode==41 and HUD==0 and keycheck==0 then
HUD=1
keycheck=1
cursor_sp=CreateSprite ( cursor_im )
end

if HUD==1 then
Text(1,1,6,"Health "..math.floor(g_PlayerHealth/10))
SetSpritePosition ( cursor_sp , 1 , 4 )
SetSpriteSize( cursor_sp,g_PlayerHealth/(initialhealth/10),3)
end

if g_Scancode==41 and HUD==1 and keycheck==0 then
DeleteSprite(cursor_sp)
HUD=0
keycheck=1
end

if keycheck==1 and g_Scancode==0 then
keycheck=0
end

--Text(50,90,6,g_MouseX.." "..g_MouseY)
--Text(50,90,6,g_Scancode)
end

PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 1st Mar 2020 12:24
Attach the script, I'll take a look and fix it for you if I can.
Been there, done that, got all the T-Shirts!
PM
absurd
4
Years of Service
User Offline
Joined: 11th Feb 2020
Location:
Posted: 1st Mar 2020 15:44
https://www.dropbox.com/s/8sfonho0pedihti/custom_hud%20%282%29.lua?dl=0

do i have to make a new folder to put these images into? and name them
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 1st Mar 2020 16:17
I meant attach the script where you did "... i just copied and pasted that code. …" and got a runtime error.

Also would be useful to know what the runtime error was.

To attach the script use the "Browse" button to locate the script and then "Upload file".
Been there, done that, got all the T-Shirts!
PM
absurd
4
Years of Service
User Offline
Joined: 11th Feb 2020
Location:
Posted: 1st Mar 2020 17:06
here you go
PM
absurd
4
Years of Service
User Offline
Joined: 11th Feb 2020
Location:
Posted: 1st Mar 2020 17:07
it wont let me attach files? maybe since i just made my account this month or something?
PM

Login to post a reply

Server time is: 2024-04-26 04:17:51
Your offset time is: 2024-04-26 04:17:51