【问题标题】:LUA Script add DelayLUA 脚本添加延迟
【发布时间】:2020-09-22 01:52:33
【问题描述】:

所以我目前正在构建的 LUA 脚本有问题。我有喷枪图案的变量,但我想在坐标之间添加 9ms 延迟,不幸的是我找不到在坐标之间添加延迟的方法。它应该看起来像这样 {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 变量添加延迟。 感谢各种帮助 结束结束结束结束结束

【问题讨论】:

  • 您是将此作为宏用于任何特定的游戏或游戏引擎,还是用于您自己的游戏?
  • 这有什么关系?
  • 因为我们不知道您是否可以导入模块,运行操作系统命令,或者是否可以在游戏API中构建任何功能
  • @LeszekMazur - 它是集成在 LGS/GHUB 中的 Lua。
  • 感谢您帮助我。我只需要用 Sleep(9) 替换 Sleep(Spray_Randomize1)。坐了几个小时才找到解决方案,但最后只需要更改一个段落,哈哈

标签: lua logitech-gaming-software


【解决方案1】:
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

【讨论】:

    猜你喜欢
    • 2023-04-05
    • 1970-01-01
    • 2014-01-26
    • 2012-03-25
    • 2010-10-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多