【问题标题】:I can't run my code?我无法运行我的代码?
【发布时间】:2014-07-09 23:49:19
【问题描述】:

我为 garry 模式编写了一个脚本,使用 lua 编写了一个脚本,该脚本允许我在绑定键时进行跳转,然后进行 360 度转弯并射击,但是当我完成编码时,它不会'不要让我对其进行测试,这是为什么,您能否偶然告诉我我在代码中做错了什么。我也有 90% 的把握转弯不会形成完整的 360,所以如果你能帮我解决这个问题,我会很感激的。谢谢。 代码:

function 360JumpShot()
    timer.simple(.01,jump)
    timer.simple(.02,turn)
    timer.simple(.04,turn)
    timer.simple(.06,turn)
    timer.simple(.08,turn)
    timer.simple(.10,turn)
    timer.Simple(.12,Turn)
    timer.Simple(.14,Turn)
    timer.Simple(.16,Turn)
    timer.Simple(.18,Turn)
    timer.Simple(.20,Turn)
    timer.Simple(.22,Turn)
    timer.Simple(.24,Turn)
    timer.Simple(.26,Turn)
    timer.Simple(.28,Turn)
    timer.Simple(.30,Turn)
    timer.Simple(.32,Turn)
    timer.Simple(.34,Turn)
    timer.Simple(.36,Turn)
    timer.Simple(.36,Turn)
    timer.Simple(.40,Turn)
    timer.Simple(.45,Turn)
    timer.Simple(.50,Turn)
    timer.Simple(.55,Turn)
    timer.Simple(.60,Turn)
    timer.Simple(.65,Turn)
    timer.Simple(.70,Turn)
-- Get Noscoped
    timer.simple(.7,function() RunConsoleCommand("+attack") end)
    timer.simple(.72,function() RunConsoleCommand("-attack") end)
end
function Turn()
-- Turn(360)
    LocalPlayer():SetEyeAngles(LocalPlayer():EyeAngles()-Angle(0,10,0))
end
function jump()
    LocalPlayer():EyeAngles() LocalPlayer():SetEyeAngles(Angle(a.p-a.p-a.p, a.y-180, a.r))
end
-- Console Command
concommand.ADD("360Jump",360JumpShot)

【问题讨论】:

  • 函数名不能以数字开头。
  • "It won't let me",这是什么意思,你得到错误了吗?如果是,则在您的问题中提供完整的错误消息。
  • 另外,有时你写simple 用大写的's',有时用小写。它应该是小写或大写

标签: lua garrys-mod


【解决方案1】:

好的,我开始工作了。

首先,你不能用数字开始你的功能,所以改变

function 360JumpShot()
concommand.ADD("360Jump",360JumpShot)

function JumpShot()
concommand.Add("360Jump",JumpShot)

请注意,我也将 ADD 更改为 Add,因为 LUA 区分大小写,考虑到.. 更改

timer.simple(.01,jump)
timer.simple(.02,turn)
timer.simple(.04,turn)
timer.simple(.06,turn)
timer.simple(.08,turn)
timer.simple(.10,turn)
timer.simple(.7,function() RunConsoleCommand("+attack") end)
timer.simple(.72,function() RunConsoleCommand("-attack") end)

timer.Simple(.01,jump)
timer.Simple(.02,Turn)
timer.Simple(.04,Turn)
timer.Simple(.06,Turn)
timer.Simple(.08,Turn)
timer.Simple(.10,Turn)
timer.Simple(.7,function() RunConsoleCommand("+attack") end)
timer.Simple(.72,function() RunConsoleCommand("-attack") end)

在这些更改之后,您的脚本可以正常工作,但您可能希望找到一种移动速度更快的方法,因为您的相机移动速度非常慢,并且可能不是您想要的。

【讨论】:

    猜你喜欢
    • 2017-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-19
    • 1970-01-01
    • 2018-03-13
    • 2020-01-21
    • 2016-05-13
    相关资源
    最近更新 更多