简体   繁体   English

lua/pivohelperv2.lua:127: ')' 附近出现意外符号

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

Pls can u help me, thats not all of the code but in this piece problem.请你帮帮我,这不是所有的代码,而是这个问题。 Thats Glua and i hope u help me!!!那是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)

add some more details!add some more details!add some more detailsadd some more detailsadd some more detailsadd some more detailsadd some more detailsadd some more detailsadd some more detailsadd some more detailsadd some more details添加更多详细信息添加更多详细信息添加更多详细信息添加更多详细信息添加更多详细信息添加更多详细信息添加更多详细信息添加更多详细信息添加更多详细信息添加更多详细信息添加更多详细信息

You have an extra end) at the end of the code block.你有一个额外的end)在代码块的末尾。 I assume that's line 127 , right?我假设那是第 127 行,对吧? That is, unless this code is inside a block that starts somewhere we can't see in your except.也就是说,除非这段代码在一个块内,该块从我们在你的例外中看不到的地方开始。

Be sure to be careful with identation when writing function blocks!编写功能块时一定要小心标识! It helps to make sure your function() blocks are properly closed with a corresponding end .它有助于确保您的function()块以相应的end正确关闭。

One extra thing.一件额外的事情。 This:这个:

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

Can instead be written as:可以改为:

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

And this:和这个:

dPanelButton1.DoClick = function()
  ...
end

Could be written as:可以写成:

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

This makes the function blocks clearer in the code and is easier for others to read.这使得代码中的功能块更清晰,也更容易被其他人阅读。 Clean readable code is how you prevent syntax errors (well, that and an IDE).干净可读的代码是您防止语法错误的方法(好吧,还有一个 IDE)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM