【问题标题】:'=' expected near 'Jumpscare"\'=\' 预计在 \'Jumpscare\" 附近
【发布时间】:2022-11-30 08:56:26
【问题描述】:
**local Jumpscare = 0

function onUpdate()
    setProperty('cpuControlled', false)
    setProperty Jumpscare = 1
    return
end

function onUpdate()
    if Jumpscare = 1 then
        playSound('PIRACY_IS_ILLEGAL!')
    end
    
end**

code does not work
please help anyone

我尝试在 cpuControlled 事件上一遍又一遍地播放声音,但它只是起作用

【问题讨论】:

    标签: lua


    【解决方案1】:

    好吧,当你用 Lua 和许多其他语言比较某些东西时,尤其是当你想知道它们是否相等时,你应该使用双等号:

    if Jumpscare == 1 then
        playSound('PIRACY_IS_ILLIGAL')
    end
    

    这是因为“=”用于将变量设置为特定值。用英语你的代码说:

    如果 ... 顺便说一句,Jumpscare 等于 1。 ... 然后

    相反,你会希望它说:

    如果 Jumpscare 等于 1,那么...

    因此“==”! 祝你有美好的一天,记得在比较值时使用“==”:D

    【讨论】:

      猜你喜欢
      • 2020-09-15
      • 2019-01-11
      • 2014-03-14
      • 2016-06-27
      • 1970-01-01
      • 1970-01-01
      • 2020-12-12
      • 2019-07-22
      • 1970-01-01
      相关资源
      最近更新 更多