• Derma Problem
    7 replies, posted
Okay, i have followed a tutorial on how to set an open button for a Derma tutorial, but whenever i press F1 ( button I set to make Derma open ) I get this: [code] :1: attempt to call global 'CharacterCreation' (a nil value) [/code] Now, this is my Clientside Code ( Just the actual DFrame, you guys aint getting your hands on my code :argh: ) [lua]local CharacterCreation = vgui.Create( "DFrame" ) CharacterCreation:SetSize( 600, 600 ) CharacterCreation:Center() CharacterCreation:SetTitle( "Garry Company Character Creation" ) CharacterCreation:SetVisible( true ) CharacterCreation:SetDraggable( false ) CharacterCreation:ShowCloseButton( true ) CharacterCreation:MakePopup()[/lua] And this is my Serverside Code for the setting F1 for open button: [lua]function GM:ShowHelp(ply) ply:SendLua("CharacterCreation()") end[/lua] What is wrong?
Theres probably more errors or something else are you sure you made that function? [lua]function CharacterCreation() local CharacterCreation = vgui.Create( "DFrame" ) CharacterCreation:SetSize( 600, 600 ) CharacterCreation:Center() CharacterCreation:SetTitle( "Garry Company Character Creation" ) CharacterCreation:SetVisible( true ) CharacterCreation:SetDraggable( false ) CharacterCreation:ShowCloseButton( true ) CharacterCreation:MakePopup() end[/lua] You probbably have to show more code...
:/ All together, the clientside Derma code is this: [lua]local CharacterCreation = vgui.Create( "DFrame" ) CharacterCreation:SetSize( 600, 600 ) CharacterCreation:Center() CharacterCreation:SetTitle( "Garry Company Character Creation" ) CharacterCreation:SetVisible( true ) CharacterCreation:SetDraggable( false ) CharacterCreation:ShowCloseButton( true ) CharacterCreation:MakePopup() local CharacterName = vgui.Create( "DTextEntry", CharacterCreation ) CharacterName:SetPos( 20, 75 ) CharacterName:SetSize( 100, 25 ) CharacterName:SetFont( "ConsoleText" ) CharacterName:SetEnterAllowed( true ) CharacterName.OnEnter( function( ply ) ply:SetName( "" ..CharacterName:GetValue() ) end ) local Title1 = "Character Name" surface.SetFont( "Trebuchet20" ) surface.SetTextColor( 255, 255, 255, 255 ) surface.SetTextPos( 20, 50 ) surface.DrawText( Title1 ) local CloseButton = vgui.Create( "DSysButton", CharacterCreation ) CloseButton:SetPos( 100, 100 ) CloseButton:SetSize( 150, 25 ) CloseButton:SetType( "close" ) CloseButton.DoClick = function() CharacterCreation:SetVisible( false ) end [/lua] ( Yeah I lied, it's not awesome, but meh )
You need to put that code in a function and call that. The function needs to be global if you are going to use SendLua.
Here: [lua]function CharacterCreation() local CharacterCreation = vgui.Create( "DFrame" ) CharacterCreation:SetSize( 600, 600 ) CharacterCreation:Center() CharacterCreation:SetTitle( "Garry Company Character Creation" ) CharacterCreation:SetVisible( true ) CharacterCreation:SetDraggable( false ) CharacterCreation:ShowCloseButton( true ) CharacterCreation:MakePopup() local CharacterName = vgui.Create( "DTextEntry", CharacterCreation ) CharacterName:SetPos( 20, 75 ) CharacterName:SetSize( 100, 25 ) CharacterName:SetFont( "ConsoleText" ) CharacterName:SetEnterAllowed( true ) CharacterName.OnEnter( function( ply ) ply:SetName( "" ..CharacterName:GetValue() ) end ) local Title1 = "Character Name" surface.SetFont( "Trebuchet20" ) surface.SetTextColor( 255, 255, 255, 255 ) surface.SetTextPos( 20, 50 ) surface.DrawText( Title1 ) local CloseButton = vgui.Create( "DSysButton", CharacterCreation ) CloseButton:SetPos( 100, 100 ) CloseButton:SetSize( 150, 25 ) CloseButton:SetType( "close" ) CloseButton.DoClick = function() CharacterCreation:SetVisible( false ) end end[/lua]
I don't think you can have the CharacterCreation for both function and local.
yeah...because then would it become function vgui.Create( "DFrame" )
Yea, you cant do that.
Sorry, you need to Log In to post a reply to this thread.