Draw
From GMod Wiki
"draw" is a library of functions used to draw HUD objects on the client's screen.
Note: the draw library is derived from surface.
Library Functions
draw.DrawText
draw.GetFontHeight
draw.NoTexture
draw.RoundedBox
draw.RoundedBoxEx
draw.SimpleText
draw.SimpleTextOutlined
draw.Text
draw.TextShadow
draw.TexturedQuad
draw.WordBox
How to use it
These have to be called continuously to show up continuously (with every think/tick), so you can't just test them from the console. A convenient way to experiment with these would be to create a lua file (Let's call it cl_test.lua) in the garrysmod\lua directory, first we create a simple function from the draw table to draw something, then we add the function to the Gamemode.HUDPaint hook. The file's contents should look something like this:
function TestDrawHud() draw.WordBox( 25, 50, 50, "Hello World","Default",Color(50,50,75,100),Color(255,255,255,255)) -- The functions you are messing around with go here end hook.Add("HUDPaint", "HUD_TEST", TestDrawHud) -- Always leave a blank line at the end of the script
Now you have your code, But it still wont show up.
Here is how you fix it.
Type this into the console:
bind \ "lua_openscript_cl cl_test.lua"
Now, every time you press the key you bound the command to (if unchanged it's backslash (\)), the file (cl_test.lua) will reload and override the preexisting hook. To edit the experimental code, just Alt+Tab to the text editor, edit the text, save, go back to Garry's Mod, and press the key you bound that command to. If there are no errors, the HUD should immediately refresh to show you the effects of the updated test script.
Additional Notes and Information
- Draw uses Surface to draw elements.
- So, if you use any Draw function that requires to set color or font, you have to set color or font again if you use Surface after Draw.