簡體   English   中英

lua/pivohelperv2.lua:127: ')' 附近出現意外符號

[英]lua/pivohelperv2.lua:127: unexpected symbol near ')'

請你幫幫我,這不是所有的代碼,而是這個問題。 那是Glua,我希望你能幫助我!!!

local dPanelButton1 = vgui.Create( 'DButton', dPanelDa) --Кнопка для лотки
    dPanelButton1:SetSize( 250, 50 )
    dPanelButton1:SetPos( 625, 370 )
    dPanelButton1:SetText( '' )

    dPanelButton1.Paint = function( self, w, h )
    draw.RoundedBox( 30, 0, 0, w, h, Color( 90, 90, 90, 200 ) )
    draw.SimpleText( "Админский ПивоХелп", "help", w / 2,  h / 2.0, Color( 224, 184, 128 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
end
    dPanelButton1.DoClick = function() 
        local dPanelDa = vgui.Create( 'DFrame') 

        dPanelDa:SetSize( 500, 300 )
        dPanelDa:SetPos( ScrW() / 2 - 450, ScrH() / 2 - 250)

        dPanelDa:SetTitle( ' Админский ПивоХелп ' )
        dPanelDa:ShowCloseButton( true )

        dPanelDa:MakePopup()

        dPanelDa.Paint = function( self, w, h )

        draw.RoundedBox( 5, 0, 0, w, h, Color(90, 90, 90, 200) )
        draw.RoundedBox( 5, 2, 2, w, 25, Color(224, 184, 128) ) 
end

end

timer.Simple( 1, function() PivoDerma() end ) -- потнич

end)

添加更多詳細信息添加更多詳細信息添加更多詳細信息添加更多詳細信息添加更多詳細信息添加更多詳細信息添加更多詳細信息添加更多詳細信息添加更多詳細信息添加更多詳細信息添加更多詳細信息

你有一個額外的end)在代碼塊的末尾。 我假設那是第 127 行,對吧? 也就是說,除非這段代碼在一個塊內,該塊從我們在你的例外中看不到的地方開始。

編寫功能塊時一定要小心標識! 它有助於確保您的function()塊以相應的end正確關閉。

一件額外的事情。 這個:

dPanelButton1.Paint = function( self, w, h )
  ...
end

可以改為:

function dPanelButton1:Paint( w, h )
  -- the 'self' arg can be omitted by using colons ":" instead of dot "." during declaration and calls.
  -- this is the most common way of passing the table the function is stored in as the first argument, implicitly named `self`.
  -- In other words, calling `dPanelButton1:Paint(1, 2)` is the same as calling `dPanelButton1.Paint(dPanelButton1, 1, 2)`
  ...
end

和這個:

dPanelButton1.DoClick = function()
  ...
end

可以寫成:

function dPanelButton1.DoClick()
  -- Writing `function foo(arg)` is the same as writing `foo = function(arg)`.
  ...
end

這使得代碼中的功能塊更清晰,也更容易被其他人閱讀。 干凈可讀的代碼是您防止語法錯誤的方法(好吧,還有一個 IDE)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM