LUA 脚本添加延迟

LUA Script add Delay

所以我目前正在构建的 LUA 脚本有问题。我有喷枪模式的变量,但我想在坐标之间添加 9 毫秒的延迟,不幸的是我找不到在坐标之间添加延迟的方法。它应该看起来像这样 {x=2,y=2}延迟{x=1,y=1}延迟...... 我知道不可能在变量中放置延迟,但我希望找到一种方法将延迟放入循环中??。 代码如下:

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(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 
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 (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 变量。 感谢各种帮助 结束结束结束结束结束

local Macro_Activation_Key = 4 
local Selection_Key = 3
local Recoil_Activator, R_Weapon_Selector = false,0

EnablePrimaryMouseButtonEvents(true)
-- d = delay to wait before moving the mouse (d=9 by default)
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 

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
            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 
            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