LUA脚本添加延迟
我目前正在编写一个LUA脚本,遇到了一个问题。 我有一个枪支喷涂模式的变量,但我想在坐标之间添加9ms的延迟。 不幸的是,我找不到一种在坐标之间添加延迟的方法。它应该像这样 {x = 2,y = 2}DELAY{x = 1,y = 1}DELAY ...... 我知道在变量中添加延迟是不可能的,但我希望能找到一种将延迟放在循环中的方法??。 以下是代码:
`` ` local Macro_Activation_Key = 4 local Selection_Key = 3 local Spray_Randomize1 = math.random(24,24) local Spray_Randomize2 = math.random(20,20.5) local Spray_Randomize3 = math.random(24,24) local Recoil_Activator R_Weapon_Selector = false,0 EnablePrimaryMouseButtonEvents(true); local AK47_Pattern = {{x = 0,y = 2},{x = 0,y = 2},{x = 0,y = 2},{x = 0,y = 3},{x = 0,y = 4},{x = 0,y = 4},{x = 0,y = 5},{x = 0,y = 8},{x = 0,y = 8},{x = 0,y = 8}} local M4A1_Pattern = {{x = 0,y = 1},{x = 0,y = 1},{x = 0,y = 2},{x = 0,y = 2},{x = 0,y = 1},{x = 0,y = 1},{x = 0,y = 2},{x = 0,y = 2},{x = 0,y = 3},{x = 0,y = 3},{x = 0,y = 3},{x = 0,y = 3},{x = 0,y = 3},{x = 0,y = 3},{x = 0,y = 3},{x = -1,y = 4},{x = -1,y = 4},{x = 0,y = 5},{x = -1,y = 5},{x = -1,y = 5},{x = 0,y = 5},{x = 0,y = 5},{x = 0,y = 5}} local function RetrieveWeaponName(武器,act)if武器== 1 then return "AK47" elseif武器== 3 then return "M4A1" end if act then return "ON_Macro" else return "OFF_Macro" end end local function OutputLogs(武器,act) OutputLogMessage(RetrieveWeaponName(武器,act).."\n "); OutputDebugMessage(RetrieveWeaponName(武器,act).."\n "); ClearLCD(); OutputLCDMessage(RetrieveWeaponName(武器,act)); end function OnEvent(event,arg)if(event == "MOUSE_BUTTON_PRESSED" and arg == Macro_Activation_Key)then Recoil_Activator = not Recoil_Activator OutputLogs(nil,Recoil_Activator) end if Recoil_Activator then if(event == "MOUSE_BUTTON_PRESSED" and arg == Selection_Key)then if R_Weapon_Selector >= 3 then R_Weapon_Selector = 0 end R_Weapon_Selector = R_Weapon_Selector + 1 OutputLogs(R_Weapon_Selector,nil) end if(R_Weapon_Selector == 1)and IsMouseButtonPressed(1)then for i = 1,# AK47_Pattern do if IsMouseButtonPressed(1)then Sleep(Spray_Randomize1) MoveMouseRelative(AK47_Pattern [ i ]。x,AK47_Pattern [ i ]。y)end end end if(R_Weapon_Selector == 3)and IsMouseButtonPressed(1)then for i = 1,# M4A1_Pattern do if IsMouseButtonPressed(1)then Sleep(Spray_Randomize3) MoveMouseRelative(M4A1_Pattern [ i ]。x,M4A1_Pattern [ i ]。y )
我想在本地AK47 \ _Pattern和M4a1 \ _Pattern变量中添加Delay。
感谢所有种类的帮助
- Lua 虚拟机加密load(string.dump(function)) 后执行失败问题如何解决
- 我想创建一个 Nginx 规则,禁止访问
- 如何将两个不同的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 代码?

local Macro_Activation_Key = 4 -- 宏开关按键 local Selection_Key = 3 -- 武器切换按键 local Recoil_Activator, R_Weapon_Selector = false,0 -- 控制反作用力开关和武器选择器 EnablePrimaryMouseButtonEvents(true) -- 启用鼠标主按钮事件 -- 枪支后坐力模拟模式 -- d = 鼠标移动前等待多久(默认是9) local AK47_Pattern = {{x=0,y=2},{d=11,x=0,y=2},{d=12,x=0,y=2},{x=0,y=3},{x=0,y=4},{x=0,y=4},{x=0,y=5},{x=0,y=8},{x=0,y=8},{x=0,y=8}} local M4A1_Pattern = {{x=0,y=1},{d=5,x=0,y=1},{d=7,x=0,y=2},{x=0,y=2},{x=0,y=1},{x=0,y=1},{x=0,y=2},{x=0,y=2},{x=0,y=3},{x=0,y=3},{x=0,y=3},{x=0,y=3},{x=0,y=3},{x=0,y=3},{x=0,y=3},{x=-1,y=4},{x=-1,y=4},{x=0,y=5},{x=-1,y=5},{x=-1,y=5},{x=0,y=5},{x=0,y=5},{x=0,y=5}} -- 根据武器编号获取武器名称以及宏开关状态 local function RetrieveWeaponName(weapon, act) if weapon == 1 then return "AK47" elseif weapon == 3 then return "M4A1" end if act then return "ON_Macro" else return "OFF_Macro" end end -- 输出日志到屏幕、调试窗口以及LCD显示屏 local function OutputLogs(weapon, act) OutputLogMessage(RetrieveWeaponName(weapon,act) .. "\n") OutputDebugMessage(RetrieveWeaponName(weapon,act) .. "\n") ClearLCD() OutputLCDMessage(RetrieveWeaponName(weapon,act)) end -- 注册鼠标事件回调函数 function OnEvent(event, arg) -- 宏开关开启/关闭 if (event == "MOUSE_BUTTON_PRESSED" and arg == Macro_Activation_Key) then Recoil_Activator = not Recoil_Activator OutputLogs(nil, Recoil_Activator) end -- 如果宏开关已经打开 if Recoil_Activator then -- 武器选择 if (event == "MOUSE_BUTTON_PRESSED" and arg == Selection_Key) then if R_Weapon_Selector >= 3 then R_Weapon_Selector = 0 end R_Weapon_Selector = R_Weapon_Selector + 1 OutputLogs(R_Weapon_Selector, nil) end -- 鼠标左键按下 if (event == "MOUSE_BUTTON_PRESSED" and arg == 1) then if R_Weapon_Selector == 1 then -- AK47后坐力模拟 for i = 1, #AK47_Pattern do Sleep(AK47_Pattern[i].d or 9) MoveMouseRelative( AK47_Pattern[i].x, AK47_Pattern[i].y ) if not IsMouseButtonPressed(1) then break end end end if R_Weapon_Selector == 3 then -- M4A1后坐力模拟 for i = 1, #M4A1_Pattern do Sleep(M4A1_Pattern[i].d or 9) MoveMouseRelative( M4A1_Pattern[i].x, M4A1_Pattern[i].y ) if not IsMouseButtonPressed(1) then break end end end end end end