• How to add text to derma?
    4 replies, posted
How do you add simple text to a derma panel? I forgot how :l
Some would say you should use a [b][url=http://wiki.garrysmod.com/?title=DLabel]DLabel[/b][/url], but personally I prefer creating a DPanel and overriding the paint hook with [b][url=wiki.garrysmod.com/?title=Draw.DrawText]Draw.DrawText [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b].
Okay, how come my entity won't update? I reloaded the gamemode, and my derma panel won't change. [editline]02:44AM[/editline] Cl_Init: [lua] function my_message_hook( um ) local DermaPanel = vgui.Create( "DFrame" ) -- Creates the frame itself DermaPanel:SetPos( 300, 500 ) -- Position on the players screen DermaPanel:SetSize( 400, 200 ) -- Size of the frame DermaPanel:SetTitle( "Bar Owner" ) -- Title of the frame DermaPanel:SetVisible( true ) DermaPanel:SetDraggable( false ) -- Draggable by mouse? DermaPanel:ShowCloseButton( true ) -- Show the close button? DermaPanel:MakePopup( true ) local TestingPanel = vgui.Create( "DPanel", DermaPanel ) TestingPanel:SetPos( 5, 25 ) TestingPanel:SetSize( 390, 170 ) TestingPanel.Paint = function() -- Paint function surface.SetDrawColor( 50, 50, 50, 255 ) -- Set our rect color below us; we do this so you can see items added to this panel surface.DrawRect( 0, 0, TestingPanel:GetWide(), TestingPanel:GetTall() ) -- Draw the rect end local Label1 = vgui.Create("Label", TestingPanel) Label1:SetPos(5,5) Label1:SetText("Hello, how can I help you? ") Label1:SizeToContents() local DermaButton8 = vgui.Create( "DButton", TestingPanel ) DermaButton8:SetParent( DermaPanel ) -- Set parent to our "DermaPanel" DermaButton8:SetText( "Nevermind" ) DermaButton8:SetPos( 10, 100 ) DermaButton8:SetSize( 380, 25 ) DermaButton8.DoClick = function () DermaPanel:SetVisible( false ) end local DermaButton5 = vgui.Create( "DButton", TestingPanel ) DermaButton5:SetParent( DermaPanel ) -- Set parent to our "DermaPanel" DermaButton5:SetText( "Are you hiring?" ) DermaButton5:SetPos( 10, 75 ) DermaButton5:SetSize( 380, 25 ) DermaButton5.DoClick = function () local DermaButton6 = vgui.Create( "DButton", TestingPanel ) DermaButton6:SetParent( DermaPanel ) -- Set parent to our "DermaPanel" DermaButton6:SetText( "Sure!" ) DermaButton6:SetPos( 10, 50 ) DermaButton6:SetSize( 380, 25 ) Label1:SetText("Yes. You you like to be a Bar Keeper?") DermaButton8:SetVisible( false ) DermaButton6.DoClick = function () end local DermaButton7 = vgui.Create( "DButton", TestingPanel ) DermaButton7:SetParent( DermaPanel ) -- Set parent to our "DermaPanel" DermaButton7:SetText( "No Thanks" ) DermaButton7:SetPos( 10, 75 ) DermaButton7:SetSize( 380, 25 ) Label1:SetText("Yes. You you like to be a Bar Keeper?") DermaButton7.DoClick = function () DermaPanel:SetVisible( false ) end end local DermaButton = vgui.Create( "DButton", TestingPanel ) DermaButton:SetParent( DermaPanel ) -- Set parent to our "DermaPanel" DermaButton:SetText( "What is this place?" ) DermaButton:SetPos( 10, 50 ) DermaButton:SetSize( 380, 25 ) DermaButton.DoClick = function () local DermaButton2 = vgui.Create( "DButton", TestingPanel ) DermaButton2:SetParent( DermaPanel ) -- Set parent to our "DermaPanel" DermaButton2:SetText( "Are you hiring?" ) DermaButton2:SetPos( 10, 50 ) DermaButton2:SetSize( 380, 25 ) DermaButton5:SetVisible( false ) DermaButton8:SetVisible( false ) Label1:SetText("Well, this would be my bar. ") DermaButton2.DoClick = function () local DermaButton3 = vgui.Create( "DButton", TestingPanel ) DermaButton3:SetParent( DermaPanel ) -- Set parent to our "DermaPanel" DermaButton3:SetText( "Sure!" ) DermaButton3:SetPos( 10, 50 ) DermaButton3:SetSize( 380, 25 ) Label1:SetText("Yes. You you like to be a Bar Keeper?") DermaButton3.DoClick = function () end local DermaButton4 = vgui.Create( "DButton", TestingPanel ) DermaButton4:SetParent( DermaPanel ) -- Set parent to our "DermaPanel" DermaButton4:SetText( "No Thanks" ) DermaButton4:SetPos( 10, 75 ) DermaButton4:SetSize( 380, 25 ) DermaButton4.DoClick = function () DermaPanel:SetVisible( false ) end end end end usermessage.Hook("my_message", my_message_hook) [/lua] Init: [lua] function ENT:AcceptInput( name, activator, caller ) umsg.Start("my_message", activator) umsg.End("my_message") end [/lua]
This might help you: [url=http://www.garrysmod.org/downloads/?a=view&id=78811][img]http://www.garrysmod.org/img/?t=dll&id=78811[/img][/url]
it has something to do with AcceptInput cause now it doesn't even work. I put print("hey"), and when I press e on it nothing happens. I also tried making the file again.. I tried the thing you told me to use, and that didn't work. I reloaded the map, and it just won't work.
Sorry, you need to Log In to post a reply to this thread.