Move location of HUD in my script?



I just released my first script entitled Street Label that shows the location of the player on the bottom left side of their screen. I made this with about 5 drawTxt functions per direction so there are a lot of drawTxt functions going on in the script as you can see in the github project here. As I released it I soon realized a lot of users want to move it around but there currently is no simple way to do so without having to adjust each and every drawTxt function which will be very difficult for those that have never adjusted .lua code before and would like to find a way to have just one element that the user will need to adjust to move the entire HUD around their display to their liking. Thank you for reading and your help in advance!

Best regards,


Set 2 variables, x and y. Your first drawtext will be at x and y. The other elements after it can be x+10.0 and y+10.0 and so on. That way, if anybody wants to move the entire thing, they just need to touch the x and y variable.

So… for example… Very basic, but I hope it gets the point across.

local x = 0.5
local y = 0.5

drawTxt(x, y, "helllo today")
drawTxt(x+0.05, y+0.05, "oh hi")


Thank you but I am a little confused as to what I need to do. I would just create

local x = 0.5
local y = 0.5

at the top of my script but won’t the users still have to adjust each drawTxt fucntion with this (that is what it looks like looking at the example you provided: drawTxt(x+0.05, y+0.05, "oh hi") there). Sorry for the confusion :frowning:


You will have to release an update that changes each drawTxt function to have the x and y variables.

Create the x and y variables. For them, put whatever screen coordinate you want the first element to be at. After that, how far away are the other elements from that first element? If your next element is 0.05 to the right of the first, you would put x+0.05 instead of 0.55. This makes it dynamic so you only have to edit the values in the variables.

In this picture, the read box is our first element. Each other box is “linked” to that and we instead put how far away we want them to be from the red box.


Ahhh I believe I understand now. I really appreciate your making an entire graph for me, thank you so much! Now back to re-scripting this :stuck_out_tongue:


No problem :wink:

I’m just shit at explaining it. Gotta show it.


Awesome, just tested it out with just the North direction and working great! Quick questiont though; How can I use a config.ini file or something of the sort in the script folder so users just have to open that and can edit the local x and local y variables from there instead of having to go in to the client.lua file and find it?!


That I am not sure. I have never done anything with config files


Thank you for the example with position. Do you know how I can do something similar with rgba color as well? I tried to create a variable called color = 255, 255, 255, 255 but does not update when I try to use the varaible in the drawTxt function like this: drawTxt(x-0.315, y+0.42, 1.0,1.0,1.0, direction, color)


You can’t assign 4 numbers to a single variable without getting intos tables and such.

What I did was

r = 255
g = 255
b = 255
a = 255

Then do

drawTxt(x-0.315, y+0.42, 1.0,1.0,1.0, direction , r, g, b, a)


Makes sense, thank you!