Lua ')' expected (to close '(' at line 19 near '<eof>')

运行下面的代码时会产生以下错误:

lua/testhud.lua:28: ')' expected (to close '(' at line 19) near ''

代码:

surface.CreateFont( "Whatever", {

    font = "Arial",
    size = 100,
    weight = 500,
    blursize = 0,
    scanlines = 0,
    antialias = true,
    underline = false,
    italic = false,
    strikeout = false,
    symbol = false,
    rotary = false,
    shadow = false,
    additive = false,
    outline = false,
} )

hook.Add( "HudPaint" , "DrawMyHud" , function( )

    local health = LocalPlayer():Health()

    draw.RoundedBox(0,8,8,300+4 , 30+4,Color(86,55,89))
    draw.RoundedBox(0,10,10,health * 3,30,Color(255,120,120))
    draw.SimpleText(health.."%","Whatever",10 + 150 , 10 + 15 ,Colour(255,255,255),1,1)

end
点赞
用户5166781
用户5166781

错误:lua/testhud.lua:28: 需要 ')'(在第19行的'('之后关闭)附近的'' 你缺少一个 ')' 以关闭第 19 行开头附近的 '('。可能应该在定义函数的 'end' 语句之后:

hook.Add( "HudPaint" , "DrawMyHud" , function()

    local health = LocalPlayer():Health()

    draw.RoundedBox(0,8,8,300+4 , 30+4,Color(86,55,89))
    draw.RoundedBox(0,10,10,health * 3,30,Color(255,120,120))
    draw.SimpleText(health.."%","Whatever",10 + 150 , 10 + 15 ,Colour(255,255,255),1,1)

end )
2017-05-24 14:52:57