Lua')'预计(关闭'('在第19行附近'<eof>'

时间:2017-05-24 14:13:48

标签: lua

尝试运行以下代码时,会产生以下错误:

  

lua / testhud.lua:28:')'预计(关闭'('第19行)''

代码:

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

1 个答案:

答案 0 :(得分:3)

  

错误: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 )