Should I create derma menus in functions or out of functions?
4 replies, posted
What I mean is, would it be better to do this:
[code]function ShowDermaMenu()
local df = vgui.Create( "DFrame" )
...
end
[/code]
or this:
[code]local df = vgui.Create( "DFrame" )
...
[/code]
you shouldn't do any derma until at least Initialize gets called (so you should make your stuff in an Initialize hook)
[QUOTE=PortalGod;48033758]you shouldn't do any derma until at least Initialize gets called (so you should make your stuff in an Initialize hook)[/QUOTE]
Thanks. Wait, I've seen TTT make vgui in separate files and not use them in initialize hooks.... are you sure?
[code]include("scoring_shd.lua")
include("corpse_shd.lua")
include("player_ext_shd.lua")
include("weaponry_shd.lua")
include("vgui/ColoredBox.lua")
include("vgui/SimpleIcon.lua")
include("vgui/ProgressBar.lua")
include("vgui/ScrollLabel.lua")
include("cl_radio.lua")
include("cl_disguise.lua")
include("cl_transfer.lua")
include("cl_targetid.lua")
include("cl_search.lua")
include("cl_radar.lua")
include("cl_tbuttons.lua")
include("cl_scoreboard.lua")
include("cl_tips.lua")
include("cl_help.lua") --cl_help from me looking through the ttt files seems to have a TON of vgui.create in functions... but I don't know what's better
include("cl_hud.lua")
include("cl_msgstack.lua")
include("cl_hudpickup.lua")
include("cl_keys.lua")
include("cl_wepswitch.lua")
include("cl_scoring.lua")
include("cl_scoring_events.lua")
include("cl_popups.lua")
include("cl_equip.lua")
include("cl_voice.lua")
function GM:Initialize()
MsgN("TTT Client initializing...")
GAMEMODE.round_state = ROUND_WAIT
LANG.Init()
self.BaseClass:Initialize()
RunConsoleCommand("ttt_spectate", GetConVar("ttt_spectator_mode"):GetInt())
end
[/code]
I could have worded it better, I kinda misread your post
ignore the part in parenthesis, making derma wherever is fine, including functions, as long as those functions don't get called until after the vgui library gets loaded
[QUOTE=PortalGod;48033833]I could have worded it better, I kinda misread your post
ignore the part in parenthesis, making derma wherever is fine, including functions, as long as those functions don't get called until after the vgui library gets loaded[/QUOTE]
Ah, okay. Before, I ALWAYS made derma just some place random in the file itself instead of in functions. It always worked fine. The reason I was asking was because I saw TTT do it differently, but it's not a problem anymore. I'll just do it randomly in the file. Thanks for the answers, though!
Sorry, you need to Log In to post a reply to this thread.