I keep getting an error on line 74.
[ERROR] addons/pointshop_cover/lua/pointshop/vgui/dpointshopitem.lua:74: '<eof>' expected near 'end'
1. unknown - addons/pointshop_cover/lua/pointshop/vgui/dpointshopitem.lua:0
This is my section of modification. The PANEL has a lot of problems. Please help.
Full code: [url]https://hastebin.com/casixulaxa.lua[/url]
[CODE]function PANEL:DoClick()
local points = PS.Config.CalculateBuyPrice(LocalPlayer(), self.Data)
if not LocalPlayer():PS_HasItem(self.Data.ID) and not LocalPlayer():PS_HasPoints(points) then
notification.AddLegacy("You don't have enough "..PS.Config.PointsName.." for this!", NOTIFY_GENERIC, 5)
notification.Paint = function(w,h)
draw.RoundedBox(0,0,0,w,h,color_black)
end
end
if LocalPlayer():PS_HasItem(self.Data.ID) then
local SellingFrame = vgui.Create( "DFrame" )
SellingFrame:SetPos( 250,250 )
SellingFrame:SetSize( 570, 90 )
SellingFrame:SetTitle( "Confirm Selling" )
SellingFrame:ShowCloseButton( false )
SellingFrame:SetVisible( true )
SellingFrame:MakePopup()
SellingFrame:Center()
SellingFrame:ShowCloseButton(false)
SellingFrame.Paint = function()
surface.SetDrawColor( 244, 244, 244, 255 )
surface.DrawRect( 0, 0, SellingFrame:GetWide(), SellingFrame:GetTall() )
surface.SetDrawColor( 32, 32, 32, 255 )
surface.DrawRect( 0, 0, SellingFrame:GetWide(), 25 )
surface.SetDrawColor( 32, 32, 32, 255 )
surface.DrawOutlinedRect( 0, 0, SellingFrame:GetWide(), SellingFrame:GetTall() )
end
end
local DermaButton = vgui.Create( "DButton" )
DermaButton:SetParent( SellingFrame )
DermaButton:SetText( "Yes" )
DermaButton:SetPos( 480, 30 )
DermaButton:SetSize( 75, 20 )
DermaButton:SetTextColor( Color(244, 244, 244, 255) )
DermaButton.DoClick = function ()
LocalPlayer():PS_SellItem(self.Data.ID)
end
DermaButton.Paint = function() -- The paint function
surface.SetDrawColor( 32, 32, 32, 255 ) -- What color do You want to paint the button (R, B, G, A)
surface.DrawRect( 0, 0, DermaButton:GetWide(), DermaButton:GetTall() ) -- Paint what coords (Used a function to figure that out)
end
local DermaButton = vgui.Create( "DButton" )
DermaButton:SetParent( SellingFrame )
DermaButton:SetText( "No" )
DermaButton:SetPos( 480, 60 )
DermaButton:SetSize( 75, 20 )
DermaButton:SetTextColor( Color(244, 244, 244, 255) )
DermaButton.DoClick = function ()
SellingFrame:SetVisible(false)
end
end
end
if LocalPlayer():PS_HasPoints(points) then
local BuyingFrame = vgui.Create( "DFrame" )
BuyingFrame:SetPos( 250,250 )
BuyingFrame:SetSize( 570, 90 )
BuyingFrame:SetTitle( "Confirm Buying" )
BuyingFrame:ShowCloseButton( false )
BuyingFrame:SetVisible( true )
BuyingFrame:MakePopup()
BuyingFrame:Center()
BuyingFrame:ShowCloseButton(false)
BuyingFrame.Paint = function()
surface.SetDrawColor( 244, 244, 244, 255 )
surface.DrawRect( 0, 0, BuyingFrame:GetWide(), BuyingFrame:GetTall() )
surface.SetDrawColor( 32, 32, 32, 255 )
surface.DrawRect( 0, 0, BuyingFrame:GetWide(), 25 )
surface.SetDrawColor( 32, 32, 32, 255 )
surface.DrawOutlinedRect( 0, 0, BuyingFrame:GetWide(), BuyingFrame:GetTall() )
end
end
local DermaButton = vgui.Create( "DButton" )
DermaButton:SetParent( BuyingFrame )
DermaButton:SetText( "Yes" )
DermaButton:SetPos( 480, 30 )
DermaButton:SetSize( 75, 20 )
DermaButton:SetTextColor( Color(244, 244, 244, 255) )
DermaButton.DoClick = function ()
LocalPlayer():PS_BuyItem(self.Data.ID)
print("Player has bought item")
end
DermaButton.Paint = function() -- The paint function
surface.SetDrawColor( 32, 32, 32, 255 ) -- What color do You want to paint the button (R, B, G, A)
surface.DrawRect( 0, 0, DermaButton:GetWide(), DermaButton:GetTall() ) -- Paint what coords (Used a function to figure that out)
end
local DermaButton = vgui.Create( "DButton" )
DermaButton:SetParent( BuyingFrame )
DermaButton:SetText( "No" )
DermaButton:SetPos( 480, 60 )
DermaButton:SetSize( 75, 20 )
DermaButton:SetTextColor( Color(244, 244, 244, 255) )
DermaButton.DoClick = function ()
BuyingFrame:SetVisible(false)
end
end
end
--[[local menu = DermaMenu(self)
if LocalPlayer():PS_HasItem(self.Data.ID) then
menu:AddOption('Sell', function()
Derma_Query('Are you sure you want to sell ' .. self.Data.Name .. '?', 'Sell Item',
'Yes', function() LocalPlayer():PS_SellItem(self.Data.ID) end,
'No', function() end
)
end)
elseif LocalPlayer():PS_HasPoints(points) then
print("Player has points")
menu:AddOption('Buy', function()
print("Player can buy item")
Derma_Query('Are you sure you want to buy ' .. self.Data.Name .. '?', 'Buy Item',
'Yes', function() LocalPlayer():PS_BuyItem(self.Data.ID) print("Player has bought item") end,
'No', function() end
)
end)
end]]
if LocalPlayer():PS_HasItem(self.Data.ID) then
menu:AddSpacer()
if LocalPlayer():PS_HasItemEquipped(self.Data.ID) then
menu:AddOption('Holster', function()
LocalPlayer():PS_HolsterItem(self.Data.ID)
end)
else
menu:AddOption('Equip', function()
LocalPlayer():PS_EquipItem(self.Data.ID)
end)
end
if LocalPlayer():PS_HasItemEquipped(self.Data.ID) and self.Data.Modify then
menu:AddSpacer()
menu:AddOption('Modify...', function()
PS.Items[self.Data.ID]:Modify(LocalPlayer().PS_Items[self.Data.ID].Modifiers)
end)
end
end
menu:Open()
end
[/CODE]
[QUOTE=Shenesis;52075679][IMG]https://vgy.me/bhHprp.png[/IMG]
That's one end too many, remove it
[editline]8th April 2017[/editline]
Actually looked over at the code and you seem to be adding ends after [URL="https://vgy.me/SIJbZN.png"]creating[/URL] [URL="https://vgy.me/uA5oDk.png"]a[/URL] [URL="https://vgy.me/3fv0yK.png"]new panel[/URL]. Don't do that[/QUOTE]
Works, but now it is having trouble closing the frame when selecting yes or no.
[ERROR] addons/pointshop_cover/lua/pointshop/vgui/dpointshopitem.lua:122: attempt to index global 'BuyingFrame' (a nil value)
1. DoClick - addons/pointshop_cover/lua/pointshop/vgui/dpointshopitem.lua:122
2. unknown - lua/vgui/dlabel.lua:232
[CODE]function PANEL:DoClick()
local points = PS.Config.CalculateBuyPrice(LocalPlayer(), self.Data)
if not LocalPlayer():PS_HasItem(self.Data.ID) and not LocalPlayer():PS_HasPoints(points) then
notification.AddLegacy("You don't have enough "..PS.Config.PointsName.." for this!", NOTIFY_GENERIC, 5)
notification.Paint = function(w,h)
draw.RoundedBox(0,0,0,w,h,color_black)
end
end
if LocalPlayer():PS_HasItem(self.Data.ID) then
local SellingFrame = vgui.Create( "DFrame" )
SellingFrame:SetPos( 250,250 )
SellingFrame:SetSize( 570, 90 )
SellingFrame:SetTitle( "Confirm Selling" )
SellingFrame:ShowCloseButton( false )
SellingFrame:SetVisible( true )
SellingFrame:MakePopup()
SellingFrame:Center()
SellingFrame:ShowCloseButton(false)
SellingFrame.Paint = function()
surface.SetDrawColor( 244, 244, 244, 255 )
surface.DrawRect( 0, 0, SellingFrame:GetWide(), SellingFrame:GetTall() )
surface.SetDrawColor( 32, 32, 32, 255 )
surface.DrawRect( 0, 0, SellingFrame:GetWide(), 25 )
surface.SetDrawColor( 32, 32, 32, 255 )
surface.DrawOutlinedRect( 0, 0, SellingFrame:GetWide(), SellingFrame:GetTall() )
end
end
local DermaButton = vgui.Create( "DButton" )
DermaButton:SetParent( SellingFrame )
DermaButton:SetText( "Yes" )
DermaButton:SetPos( 480, 30 )
DermaButton:SetSize( 75, 20 )
DermaButton:SetTextColor( Color(244, 244, 244, 255) )
DermaButton.DoClick = function ()
LocalPlayer():PS_SellItem(self.Data.ID)
SellingFrame:SetVisible(false)
end
DermaButton.Paint = function() -- The paint function
surface.SetDrawColor( 32, 32, 32, 255 ) -- What color do You want to paint the button (R, B, G, A)
surface.DrawRect( 0, 0, DermaButton:GetWide(), DermaButton:GetTall() ) -- Paint what coords (Used a function to figure that out)
end
local DermaButton = vgui.Create( "DButton" )
DermaButton:SetParent( SellingFrame )
DermaButton:SetText( "No" )
DermaButton:SetPos( 480, 60 )
DermaButton:SetSize( 75, 20 )
DermaButton:SetTextColor( Color(244, 244, 244, 255) )
DermaButton.DoClick = function ()
SellingFrame:SetVisible(false)
end
if LocalPlayer():PS_HasPoints(points) then
local BuyingFrame = vgui.Create( "DFrame" )
BuyingFrame:SetPos( 250,250 )
BuyingFrame:SetSize( 570, 90 )
BuyingFrame:SetTitle( "Confirm Buying" )
BuyingFrame:ShowCloseButton( false )
BuyingFrame:SetVisible( true )
BuyingFrame:MakePopup()
BuyingFrame:Center()
BuyingFrame:ShowCloseButton(false)
BuyingFrame.Paint = function()
surface.SetDrawColor( 244, 244, 244, 255 )
surface.DrawRect( 0, 0, BuyingFrame:GetWide(), BuyingFrame:GetTall() )
surface.SetDrawColor( 32, 32, 32, 255 )
surface.DrawRect( 0, 0, BuyingFrame:GetWide(), 25 )
surface.SetDrawColor( 32, 32, 32, 255 )
surface.DrawOutlinedRect( 0, 0, BuyingFrame:GetWide(), BuyingFrame:GetTall() )
end
end
local DermaButton = vgui.Create( "DButton" )
DermaButton:SetParent( BuyingFrame )
DermaButton:SetText( "Yes" )
DermaButton:SetPos( 480, 30 )
DermaButton:SetSize( 75, 20 )
DermaButton:SetTextColor( Color(244, 244, 244, 255) )
DermaButton.DoClick = function ()
LocalPlayer():PS_BuyItem(self.Data.ID)
print("Player has bought item")
BuyingFrame:SetVisible(false)
end
DermaButton.Paint = function() -- The paint function
surface.SetDrawColor( 32, 32, 32, 255 ) -- What color do You want to paint the button (R, B, G, A)
surface.DrawRect( 0, 0, DermaButton:GetWide(), DermaButton:GetTall() ) -- Paint what coords (Used a function to figure that out)
end
local DermaButton = vgui.Create( "DButton" )
DermaButton:SetParent( BuyingFrame )
DermaButton:SetText( "No" )
DermaButton:SetPos( 480, 60 )
DermaButton:SetSize( 75, 20 )
DermaButton:SetTextColor( Color(244, 244, 244, 255) )
DermaButton.DoClick = function ()
BuyingFrame:SetVisible(false)
end
local menu = DermaMenu(self)
--[[if LocalPlayer():PS_HasItem(self.Data.ID) then
menu:AddOption('Sell', function()
Derma_Query('Are you sure you want to sell ' .. self.Data.Name .. '?', 'Sell Item',
'Yes', function() LocalPlayer():PS_SellItem(self.Data.ID) end,
'No', function() end
)
end)
elseif LocalPlayer():PS_HasPoints(points) then
print("Player has points")
menu:AddOption('Buy', function()
print("Player can buy item")
Derma_Query('Are you sure you want to buy ' .. self.Data.Name .. '?', 'Buy Item',
'Yes', function() LocalPlayer():PS_BuyItem(self.Data.ID) print("Player has bought item") end,
'No', function() end
)
end)
end]]
if LocalPlayer():PS_HasItem(self.Data.ID) then
menu:AddSpacer()
if LocalPlayer():PS_HasItemEquipped(self.Data.ID) then
menu:AddOption('Holster', function()
LocalPlayer():PS_HolsterItem(self.Data.ID)
end)
else
menu:AddOption('Equip', function()
LocalPlayer():PS_EquipItem(self.Data.ID)
end)
end
if LocalPlayer():PS_HasItemEquipped(self.Data.ID) and self.Data.Modify then
menu:AddSpacer()
menu:AddOption('Modify...', function()
PS.Items[self.Data.ID]:Modify(LocalPlayer().PS_Items[self.Data.ID].Modifiers)
end)
end
end
menu:Open()
end[/CODE]
You have BuyingFrame defined in the "LocalPlayer():PS_HasPoints(points)" if-statement, but you reference it outside of that scope. Wrong end placement, maybe?
[QUOTE=code_gs;52076163]You have BuyingFrame defined in the "LocalPlayer():PS_HasPoints(points)" if-statement, but you reference it outside of that scope. Wrong end placement, maybe?[/QUOTE]
A bit confused. Here is the full code for reference.
[url]https://hastebin.com/pirowoxayo.lua[/url]
One of my first DERMA attempts. Sorry :)
New Error:
[ERROR] addons/pointshop_cover/lua/pointshop/vgui/dpointshopitem.lua:107: attempt to index global 'BuyingFrame' (a nil value)
1. DoClick - addons/pointshop_cover/lua/pointshop/vgui/dpointshopitem.lua:107
2. unknown - lua/vgui/dlabel.lua:232
Here's what I mean:
[code]if (true) then
local foobar = "blah"
end
print(foobar)[/code]
This will print nil since foobar is local to the if-statement scope. You should include the elements being paired to BuyingFrame inside the if-statement with it.
[QUOTE=code_gs;52076206]Here's what I mean:
[code]if (true) then
local foobar = "blah"
end
print(foobar)[/code]
This will print nil since foobar is local to the if-statement scope. You should include the elements being paired to BuyingFrame inside the if-statement with it.[/QUOTE]
Edit: Just read the foobar part. Testing that now.
Here you go:
200
nil
Panel: [name:DButton][class:Label][480,60,75,20]
Player has bought item
[ERROR] addons/pointshop_cover/lua/pointshop/vgui/dpointshopitem.lua:111: attempt to index global 'BuyingFrame' (a nil value)
1. DoClick - addons/pointshop_cover/lua/pointshop/vgui/dpointshopitem.lua:111
2. unknown - lua/vgui/dlabel.lua:232
Code:
[CODE]if LocalPlayer():PS_HasPoints(points) then
print(points)
local BuyingFrame = vgui.Create( "DFrame" )
BuyingFrame:SetPos( 250,250 )
BuyingFrame:SetSize( 570, 90 )
BuyingFrame:SetTitle( "Confirm Buying" )
BuyingFrame:ShowCloseButton( false )
BuyingFrame:SetVisible( true )
BuyingFrame:MakePopup()
BuyingFrame:Center()
BuyingFrame:ShowCloseButton(false)
BuyingFrame.Paint = function()
surface.SetDrawColor( 244, 244, 244, 255 )
surface.DrawRect( 0, 0, BuyingFrame:GetWide(), BuyingFrame:GetTall() )
surface.SetDrawColor( 32, 32, 32, 255 )
surface.DrawRect( 0, 0, BuyingFrame:GetWide(), 25 )
surface.SetDrawColor( 32, 32, 32, 255 )
surface.DrawOutlinedRect( 0, 0, BuyingFrame:GetWide(), BuyingFrame:GetTall() )
end
end
print(BuyingFrame)
local DermaButton = vgui.Create( "DButton" )
DermaButton:SetParent( BuyingFrame )
DermaButton:SetText( "Yes" )
DermaButton:SetPos( 480, 30 )
DermaButton:SetSize( 75, 20 )
DermaButton:SetTextColor( Color(244, 244, 244, 255) )
DermaButton.DoClick = function ()
LocalPlayer():PS_BuyItem(self.Data.ID)
print("Player has bought item")
BuyingFrame:SetVisible(false)
end
DermaButton.Paint = function() -- The paint function
surface.SetDrawColor( 32, 32, 32, 255 ) -- What color do You want to paint the button (R, B, G, A)
surface.DrawRect( 0, 0, DermaButton:GetWide(), DermaButton:GetTall() ) -- Paint what coords (Used a function to figure that out)
end
local DermaButton = vgui.Create( "DButton" )
DermaButton:SetParent( BuyingFrame )
DermaButton:SetText( "No" )
DermaButton:SetPos( 480, 60 )
DermaButton:SetSize( 75, 20 )
DermaButton:SetTextColor( Color(244, 244, 244, 255) )
DermaButton.DoClick = function ()
BuyingFrame:SetVisible(false)
end
print(DermaButton)
local menu = DermaMenu(self)[/CODE]
Look at your BuyingFrame print -- it's still not defined even though you are setting it as the parent of the DermaButton. Those elements should be inside your PS_HasPoints if-statement, but you are ending it early. I don't even think you are intending to since your "end" is not tabbed in-line with the if-statement start.
[QUOTE=code_gs;52076299]Look at your BuyingFrame print -- it's still not defined even though you are setting it as the parent of the DermaButton. Those elements should be inside your PS_HasPoints if-statement, but you are ending it early. I don't even think you are intending to since your "end" is not tabbed in-line with the if-statement start.[/QUOTE]
Right, so I did something. It works with the panel now. However it has a second button on the top?
Apparently it is the selling box on the top.
Debug Analysis:
[Buying Function]
200
Panel: [name:DFrame][class:LuaEditablePanel][675,495,570,90]
Panel: [name:DButton][class:Label][480,30,75,20]
Panel: [name:DButton][class:Label][480,60,75,20]
[Selling Function]
black
Successfully received Data ID
nil
Panel: [name:DButton][class:Label][480,30,75,20]
Panel: [name:DButton][class:Label][480,60,75,20]
[IMG]http://i.imgur.com/DsR89yb.png[/IMG]
[CODE]function PANEL:DoClick()
local points = PS.Config.CalculateBuyPrice(LocalPlayer(), self.Data)
if not LocalPlayer():PS_HasItem(self.Data.ID) and not LocalPlayer():PS_HasPoints(points) then
notification.AddLegacy("You don't have enough "..PS.Config.PointsName.." for this!", NOTIFY_GENERIC, 5)
notification.Paint = function(w,h)
draw.RoundedBox(0,0,0,w,h,color_black)
end
end
if LocalPlayer():PS_HasItem(self.Data.ID) then
print(self.Data.ID)
print("Successfully received Data ID")
local SellingFrame = vgui.Create( "DFrame" )
SellingFrame:SetPos( 250,250 )
SellingFrame:SetSize( 570, 90 )
SellingFrame:SetTitle( "Confirm Sell" )
SellingFrame:ShowCloseButton( false )
SellingFrame:SetVisible( true )
SellingFrame:MakePopup()
SellingFrame:Center()
SellingFrame.Paint = function()
surface.SetDrawColor( 244, 244, 244, 255 )
surface.DrawRect( 0, 0, SellingFrame:GetWide(), SellingFrame:GetTall() )
surface.SetDrawColor( 32, 32, 32, 255 )
surface.DrawRect( 0, 0, SellingFrame:GetWide(), 25 )
surface.SetDrawColor( 32, 32, 32, 255 )
surface.DrawOutlinedRect( 0, 0, SellingFrame:GetWide(), SellingFrame:GetTall() )
end
end
print(SellingFrame)
local DermaButton = vgui.Create( "DButton", SellingFrame )
--DermaButton:SetParent( SellingFrame )
DermaButton:SetText( "Sell" )
DermaButton:SetPos( 480, 30 )
DermaButton:SetSize( 75, 20 )
DermaButton:SetTextColor( Color(244, 244, 244, 255) )
DermaButton.DoClick = function ()
LocalPlayer():PS_SellItem(self.Data.ID)
SellingFrame:SetVisible(false)
end
DermaButton.Paint = function() -- The paint function
surface.SetDrawColor( 32, 32, 32, 255 ) -- What color do You want to paint the button (R, B, G, A)
surface.DrawRect( 0, 0, DermaButton:GetWide(), DermaButton:GetTall() ) -- Paint what coords (Used a function to figure that out)
end
print(DermaButton)
local DermaButton = vgui.Create( "DButton", SellingFrame )
--DermaButton:SetParent( SellingFrame )
DermaButton:SetText( "Cancel" )
DermaButton:SetPos( 480, 60 )
DermaButton:SetSize( 75, 20 )
DermaButton:SetTextColor( Color(244, 244, 244, 255) )
DermaButton.DoClick = function ()
SellingFrame:SetVisible(false)
end
DermaButton.Paint = function()
surface.SetDrawColor( 32, 32, 32, 255 )
surface.DrawRect( 0, 0, DermaButton:GetWide(), DermaButton:GetTall() )
end
print(DermaButton)
if LocalPlayer():PS_HasPoints(points) then -- THIS NEEDS TO BE ELSEIF, but it causes a lot of errors... :/
print(points)
local BuyingFrame = vgui.Create( "DFrame" )
BuyingFrame:SetPos( 250,250 )
BuyingFrame:SetSize( 570, 90 )
BuyingFrame:SetTitle( "Confirm Purchase" )
BuyingFrame:ShowCloseButton( false )
BuyingFrame:SetVisible( true )
BuyingFrame:MakePopup()
BuyingFrame:Center()
BuyingFrame.Paint = function()
surface.SetDrawColor( 244, 244, 244, 255 )
surface.DrawRect( 0, 0, BuyingFrame:GetWide(), BuyingFrame:GetTall() )
surface.SetDrawColor( 32, 32, 32, 255 )
surface.DrawRect( 0, 0, BuyingFrame:GetWide(), 25 )
surface.SetDrawColor( 32, 32, 32, 255 )
surface.DrawOutlinedRect( 0, 0, BuyingFrame:GetWide(), BuyingFrame:GetTall() )
end
print(BuyingFrame)
local DermaButton = vgui.Create( "DButton", BuyingFrame )
--DermaButton:SetParent( BuyingFrame )
DermaButton:SetText( "Purchase" )
DermaButton:SetPos( 480, 30 )
DermaButton:SetSize( 75, 20 )
DermaButton:SetTextColor( Color(244, 244, 244, 255) )
DermaButton.DoClick = function ()
LocalPlayer():PS_BuyItem(self.Data.ID)
print("Player has bought item")
BuyingFrame:SetVisible(false)
end
DermaButton.Paint = function() -- The paint function
surface.SetDrawColor( 32, 32, 32, 255 ) -- What color do You want to paint the button (R, B, G, A)
surface.DrawRect( 0, 0, DermaButton:GetWide(), DermaButton:GetTall() ) -- Paint what coords (Used a function to figure that out)
end
print(DermaButton)
local DermaButton = vgui.Create( "DButton", BuyingFrame )
--DermaButton:SetParent( BuyingFrame )
DermaButton:SetText( "Cancel" )
DermaButton:SetPos( 480, 60 )
DermaButton:SetSize( 75, 20 )
DermaButton:SetTextColor( Color(244, 244, 244, 255) )
DermaButton.DoClick = function ()
BuyingFrame:SetVisible(false)
end
DermaButton.Paint = function()
surface.SetDrawColor( 32, 32, 32, 255 )
surface.DrawRect( 0, 0, DermaButton:GetWide(), DermaButton:GetTall() )
end
print(DermaButton)
end[/CODE]
Sorry, you need to Log In to post a reply to this thread.