Error: [QUOTE]attempt to index global 'self' (a nil value)
[/QUOTE]
[CODE]PanelTable = {}
function CreatePanel()
PanelTable.base = vgui.Create("DFrame")
PanelTable.base:SetSize(1800, 1000)
PanelTable.base:SetPos(ScrW() / 2 - PanelTable.base:GetWide() / 2, ScrH() / 2 - PanelTable.base:GetTall() / 2)
PanelTable.base:ShowCloseButton(true)
PanelTable.base:MakePopup()
PanelTable.base:SetVisible(true)
PanelTable.base:SetDraggable(true)
PanelTable.base:SetTitle("Instructor Panel")
MyTabs = vgui.Create( "DPropertySheet",PanelTable.base )
MyTabs:SetPos( 10, 30 )
MyTabs:SetSize( 1700, 900 )
FirePanel = vgui.Create("DPanel",MyTabs)
FirePanel:SetSize(1700, 900)
FirePanel:SetPos(10,30,1)
FirePanel:SetDrawBackground( false ) //The background of the panel will now be transparent, this does NOT include the tabs, which will draw as normal.
MyTabs:AddSheet( "Main", FirePanel, nill, false, false, "Fire Scenario Commands here" )
PanelTable.Button1 = vgui.Create( "DButton", FirePanel )
PanelTable.Button1:SetSize(200, 100)
PanelTable.Button1:SetPos(10,10,3)
PanelTable.Button1:SetText( "Button 1" )
PanelTable.Button1.DoClick = function ()
self.Pressed = true
end
PanelTable.Button2 = vgui.Create( "DButton", FirePanel )
PanelTable.Button2:SetSize(200, 100)
PanelTable.Button2:SetPos(220,10,3)
PanelTable.Button2:SetText( "Button 2" )
PanelTable.Button2.DoClick = function ()
self.Pressed = true
end
PanelTable.Button3 = vgui.Create( "DButton", FirePanel )
PanelTable.Button3:SetSize(200, 100)
PanelTable.Button3:SetPos(440,10,3)
PanelTable.Button3:SetText( "Button 3" )
PanelTable.Button3.DoClick = function ()
self.Pressed = true
end
// PanelTable.button1 = vgui.Create("DButton", PanelTable.base)
-- Do more stuff here
end
function ClearTable()
PanelTable = {}
end
concommand.Add('instructorpanel',CreatePanel)[/CODE]
Is it just because I didn't use local where I should have?
When giving the error make sure to copy the whole error, line/column numbers and the stack as well. Also I don't know if this is just an issue from you copy pasting but fix the indentation.
[code]
PanelTable.Button1.DoClick = function()
self.Pressed = true
end
[/code]
You're missing `self` in your function params.
[CODE]PanelTable.Button1.DoClick = function()
self.Pressed = true
end[/CODE]
The above code will produce errors because "self" is not being registered inside the function as itself because you are defining a new function without using the colons.
[CODE]function PanelTable.Button1:DoClick()
self.Pressed = true
end[/CODE]
The above code will probably work. Untested.
[QUOTE=Maravis;48760449][CODE]PanelTable.Button1.DoClick = function()
self.Pressed = true
end[/CODE]
The above code will produce errors because "self" is not being registered inside the function as itself because you are defining a new function without using the colons.
[CODE]function PanelTable.Button1:DoClick()
self.Pressed = true
end[/CODE]
The above code will probably work. Untested.[/QUOTE]
Thanks, that got it.
Sorry, you need to Log In to post a reply to this thread.