• Editable Hud
    2 replies, posted
I have a working HUD and a Derma menu to go along with it which would act as an editor that can change colors, position, etc. How can I link the two files so they can share variables so when I set a color in the Derma menu, the HUD file will be able to use that new color? Does that make sense? Could this have anything to do with [b][url=http://wiki.garrysmod.com/?title=G.include]G.include [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] ??
File 1: config.lua [lua]HUD_BGCOLOR = Color(255,0,0) HUD_FGCOLOR = Color(0,0,255)[/lua] File 2: hud.lua [lua]include("config.lua") hook.Add("HUDPaint","HUD",function() draw.RoundedBox( 0, 0, 0, ScrW(), 25, HUD_BGCOLOR ) draw.RoundedBOx( 0, 2, 2, ScrW() - 4, 21, HUD_FGCOLOR ) end)[/lua] That would use the variables background and foreground color to draw a box at the top of the screen. So yes, you are supposed to use "include".
[QUOTE=Entoros;22478611]File 1: config.lua [lua]Awesome Code.[/lua] File 2: hud.lua [lua]Awesome code.[/lua] <Super awesome explanation.> <Agreeing statement here.>[/QUOTE] Thats friggin' amazing. Thank you very much. *Adds Entoros to credits*
Sorry, you need to Log In to post a reply to this thread.