我无法运行我的代码?
2014-7-9 23:56:55
收藏:0
阅读:76
评论:1
我为 Garry's Mod 编写了一个脚本,使用 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)
-- 获取 Noseope
timer.simple(.7,function() RunConsoleCommand("+attack") end)
timer.simple(.72,function() RunConsoleCommand("-attack") end)
end
function 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
-- 控制台命令
concommand.ADD("360Jump",360JumpShot)
点赞
评论区的留言会收到邮件通知哦~
推荐文章
- 如何将两个不同的lua文件合成一个 东西有点长 大佬请耐心看完 我是小白研究几天了都没搞定
- 如何在roblox studio中1:1导入真实世界的地形?
- 求解,lua_resume的第二次调用继续执行协程问题。
- 【上海普陀区】内向猫网络招募【Skynet游戏框架Lua后端程序员】
- SF爱好求教:如何用lua实现游戏内调用数据库函数实现账号密码注册?
- Lua实现网站后台开发
- LUA错误显式返回,社区常见的规约是怎么样的
- lua5.3下载库失败
- 请问如何实现文本框内容和某个网页搜索框内容连接,并把网页输出来的结果反馈到另外一个文本框上
- lua lanes多线程使用
- 一个kv数据库
- openresty 有没有比较轻量的 docker 镜像
- 想问一下,有大佬用过luacurl吗
- 在Lua执行过程中使用Load函数出现问题
- 为什么 neovim 里没有显示一些特殊字符?
- Lua比较两个表的值(不考虑键的顺序)
- 有个lua简单的项目,外包,有意者加微信 liuheng600456详谈,最好在成都
- 如何在 Visual Studio 2022 中运行 Lua 代码?
- addEventListener 返回 nil Lua
- Lua中获取用户配置主目录的跨平台方法
好的,我已经让它工作了。
首先,你不能以数字开头命名函数,所以把
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)在这些更改之后,你的脚本可以正常工作,但你可能需要找到一种更快的移动方式,因为你的相机移动非常缓慢,可能并不是你想要的。