1

So I've got my first macro capable keyboard (Logitech G110), and would like to utilize it for my gaming. However, my education in programming ended halfway through C programming. I am looking for help with a very simple script, that sets a timer for a delayed macro, i.e. I press a button, and after N seconds it plays a macro. Here's what I've got:

function OnEvent(event, arg)

    if(event == "G_PRESSED" and arg == 6) then
        Sleep(360000);
        PlayMacro("Dragon");
    end

    if(event == "G_PRESSED" and arg == 5) then
       Sleep(300000);
       PlayMacro("Buff");
    end

    if(event == "G_PRESSED" and arg == 12) then
       Sleep(420000);
       PlayMacro(Nashor);
    end

    if(event == "G_PRESSED" and arg == 10) then
       Sleep(300000);
       PlayMacro(FlashHeal);
    end

    if(event == "G_PRESSED" and arg == 4) then
       Sleep(210000);
       PlayMacro(IgniteExhaust);
    end

end

The problem is that it seems to not sleep for the desired amount of time, and seems to be firing at random. If I start more than one timer, the script just completely collapses and randomly fires until I restart my computer.

4

1 回答 1

0

所以这根本行不通,因为 LUA 不能同时进行多个操作。它将逐行运行代码。如果按下按钮,脚本将等待 N 秒,然后运行宏。然而,在这 N 秒内,它对任何其他输入完全没有响应。如果您按下更多按钮,它们将只是一个接一个地排队。因此,如果您紧接着按下两个按钮,脚本将等待 N 秒,然后执行宏,然后等待 N 秒,然后执行宏。没有(简单的)方法可以在 LUA 本身中获得您想要的东西,但是由于您使用 Logitech 游戏软件(我想),您可能只想在 lua 之外的宏本身中添加暂停。这确实有效。

于 2016-07-19T20:23:15.663 回答