'<eof>' line 20 附近预期的是 'function'

我的 Lua 脚本出错了,你可以看到以下脚本并自行了解。下面是该脚本

function opponentNoteHit()
    health = getProperty('health')
    if getProperty('health') > 0.05 then
        setProperty('health', health- 0.02);
    end
end

function onCreate()

    --添加 Lua 精灵
    addCharacterToList('yotsugameoverscreen', 'boyfriend');

   makeAnimatedLuaSprite('yotsugameoverscreen', 'yotsugameoverscreen');
    luaSpriteAddAnimationByPrefix('yotsugameoverscreen', 'missyotright', 'miss_yot_right', 24, false)
    luaSpriteAddAnimationByPrefix('yotsugameoverscreen', 'missyotright', 'miss_yot_right', 24, true)
    luaSpriteAddAnimationByPrefix('yotsugameoverscreen', 'yotidle', 'yot_idle', 24, false)
         end
return Function_Continue

function onCreate()
    setPropertyFromClass('GameOverSubstate','characterName', 'yotsugameoverscreen'); --对于死亡动画,字符 json 文件
end

错误是 '' 行 20 附近预期的是 'function'

原文链接 https://stackoverflow.com/questions/70683054

点赞
stackoverflow用户2858170
stackoverflow用户2858170

return是代码块中的最后一条语句。不能在其后面定义函数,例如:

return Function_Continue

function onCreate()
    setPropertyFromClass('GameOverSubstate','characterName', 'yotsugameoverscreen'); --Character json file for the death animation
end

如果你想跳过函数定义,可以这样做:

do return Function_Continue end

我不知道你想做什么,但只有另外两个选项,要么将return Function_Continue移到文件末尾,要么移到其中一个函数中。

也许你只是将end放错了行?

2022-01-12 17:01:56