• Updating scoreboard with image changes, checking my understanding...
    0 replies, posted
[CODE]local scoreimage = scoreimage or {} function scoreimage:show() local frame = vgui.Create("DFrame") frame:SetPos( 100, 100 ) frame:SetSize( 1680,950 ) frame:Center() frame:SetTitle("Quick Reference") local image1 = vgui.Create( "DImage", Frame ) -- Add image to Frame image1:SetPos( 200, 400 ) -- Move it into frame image1:SetSize( 1200, 450 ) -- Size it to 150x150 image1:SetImage("image1.png") function scoreimage:hide() frame:SetVisible(false) image1:SetVisible(false) end end hook.Add("ScoreboardShow", "quickref", function() scoreimage:show() end) hook.Add("ScoreboardHide", "quickref2", function() scoreimage:hide() end)[/CODE] Works great. Now I want to see if I can expand my understanding further and change the image based on either key-presses or commands enter to chat. First step, should I just move the image references out of this and declare them outside of the function as global variables. Then once the image info is a global variable, call it in the function by using [CODE]vgui.Create( "DImage", Frame ) -- Add image to Frame image1:SetPos( 200, 400 ) -- Move it into frame [/CODE] Is this the correct thinking? Or am I missing something?
Sorry, you need to Log In to post a reply to this thread.