Hi all i have a keyboard G105
i trying to make a litle script, ist working but it dont want to stop.
I will like to G1 on and G2 off. thx
**Macro LIST**
skill Selfbuff -- use after any playmacro "Petx" after reuse time
1 PlayMacro(selfbuff1) Sleep (1800000) --30 minutes
2 PlayMacro(selfbuff2) Sleep (600000) -- 10 minutes
-- add more
Skill Empower -- use after any playmacro "Petx" if none of then are
runing, can be at same time with "Skill Sellbuff" list
1 PlayMacro(Boost1) Reuse time = 480 seconds,Boosting time = 60 seconds
2 PlayMacro(Boost2) Reuse time = 600 seconds, Boosting time = 180 seconds
-- add more
-- G1 = 2pet
-- G2 = 3pet
local function interruptable_sleep(delay)
local tm = GetRunningTime() + delay
repeat
if IsKeyLockOn("scrolllock") then return true end
local t = tm - GetRunningTime()
if t > 0 then Sleep(math.min(t, 100)) end
until t <= 0
end
function OnEvent(event, arg)
if event=="G_PRESSED" and arg==1 then
repeat
local exit
for _, phase in ipairs{
{macro = "Basicos1", sleep_macro = 16000, },
{macro = "Pick", sleep_macro = 2000, },
{macro = "Pet1", sleep_macro = 2000, },
-- if on reuse PlayMacro(selfbuff1),PlayMacro(Selfbuff2), may add more
-- if on reuse PlayMacro(boots1),PlayMacro(boost2) may add some
{macro = "Basicos1", sleep_macro = 16000, },
{macro = "Pick", sleep_macro = 2000, },
{macro = "Pet2", sleep_macro = 2000, },
-- if on reuse PlayMacro(selfbuff1),PlayMacro(Selfbuff2), may add more
-- if on reuse PlayMacro(boots1),PlayMacro(boost2) may add some
{macro = "Basicos1", sleep_macro = 16000, },
{macro = "Pick", sleep_macro = 2000, },
} do
PlayMacro(phase.macro)
exit = interruptable_sleep(phase.sleep_macro)
AbortMacro()
if exit then break end
end
until exit
PressAndReleaseKey("scrolllock")
end
end
I really appreciate your help, but I can't understand well, I think the explanation from before has not been enough I know I don't understand much about programming but something I came to understand
This is my full script thaks to you
local function interruptable_sleep(delay)
local tm = GetRunningTime() + delay
repeat
if IsKeyLockOn("scrolllock") then return true end
local t = tm - GetRunningTime()
if t > 0 then Sleep(math.min(t, 100)) end
until t <= 0
end
function OnEvent(event, arg)
if event=="G_PRESSED" and arg==1 then
repeat
local exit
for _, phase in ipairs{
{macro = "Basicos1", sleep_macro = 16000, },
{macro = "Pick", sleep_macro = 2000, },
{macro = "Pet1", sleep_macro = 2000, },
{macro = "Basicos1", sleep_macro = 16000, },
{macro = "Pick", sleep_macro = 2000, },
{macro = "Pet2", sleep_macro = 2000, },
{macro = "Basicos1", sleep_macro = 16000, },
{macro = "Pick", sleep_macro = 2000, },
} do
PlayMacro(phase.macro)
exit = interruptable_sleep(phase.sleep_macro)
AbortMacro()
if exit then break end
end
until exit
Sleep(250)
PressAndReleaseKey("scrolllock")
elseif event=="G_PRESSED" and arg==2 then
repeat
local exit
for _, phase in ipairs{
{macro = "Basicos1", sleep_macro = 16000, },
{macro = "Pick", sleep_macro = 2000, },
{macro = "Pet1", sleep_macro = 2000, },
{macro = "Basicos1", sleep_macro = 16000, },
{macro = "Pick", sleep_macro = 2000, },
{macro = "Pet2", sleep_macro = 2000, },
{macro = "Basicos1", sleep_macro = 16000, },
{macro = "Pick", sleep_macro = 2000, },
{macro = "Pet3", sleep_macro = 2000, },
{macro = "Basicos1", sleep_macro = 16000, },
{macro = "Pick", sleep_macro = 2000, },
} do
PlayMacro(phase.macro)
exit = interruptable_sleep(phase.sleep_macro)
AbortMacro()
if exit then break end
end
until exit
Sleep(250)
PressAndReleaseKey("scrolllock")
elseif event=="G_PRESSED" and arg==3 then
repeat
local exit
for _, phase in ipairs{
{macro = "Basicos1", sleep_macro = 13000, },
{macro = "Pick", sleep_macro = 1000, },
{macro = "PetLargo1", sleep_macro = 2800, },
{macro = "Basicos1", sleep_macro = 13000, },
{macro = "Pick", sleep_macro = 1000, },
{macro = "PetLargo2", sleep_macro = 2800, },
} do
PlayMacro(phase.macro)
exit = interruptable_sleep(phase.sleep_macro)
AbortMacro()
if exit then break end
end
until exit
Sleep(250)
PressAndReleaseKey("scrolllock")
elseif event=="G_PRESSED" and arg==4 then
repeat
local exit
for _, phase in ipairs{
{macro = "Basicos1", sleep_macro = 16000, },
{macro = "Pick", sleep_macro = 2000, },
{macro = "PetLargo1", sleep_macro = 2800, },
{macro = "Basicos1", sleep_macro = 16000, },
{macro = "Pick", sleep_macro = 2000, },
{macro = "PetLargo2", sleep_macro = 2800, },
{macro = "Basicos1", sleep_macro = 16000, },
{macro = "Pick", sleep_macro = 2000, },
{macro = "PetLargo3", sleep_macro = 2800, },
{macro = "Basicos1", sleep_macro = 16000, },
{macro = "Pick", sleep_macro = 2000, },
} do
PlayMacro(phase.macro)
exit = interruptable_sleep(phase.sleep_macro)
AbortMacro()
if exit then break end
end
until exit
Sleep(250)
PressAndReleaseKey("scrolllock")
elseif event=="G_PRESSED" and arg==5 then
repeat
local exit
for _, phase in ipairs{
{macro = "Basicos1", sleep_macro = 16000,},
{macro = "Pick", sleep_macro = 500,},
} do
PlayMacro(phase.macro)
exit = interruptable_sleep(phase.sleep_macro)
AbortMacro()
if exit then break end
end
until exit
Sleep(250)
PressAndReleaseKey("scrolllock")
end
end
Is made for diferents spot at game for auto farming
I will like to G1 on and G2 off.
IMO, it's impossible to stop your script with G2 or G1.
But you can use ScrollLock key to stop the script:
Initially the ScrollLock LED is off.
You press G1, the script starts.
While the script is running, you press ScrollLock, its LED turns on.
The script finishes its work and turns the ScrollLock LED off.
function OnEvent(event, arg)
if event=="G_PRESSED" and arg==1 then
repeat
for _, Fkey in ipairs{"F1", "F2"} do
PlayMacro("Basicos")
for t = 1, 20 do
Sleep(1000)
if IsKeyLockOn("scrolllock") then break end
end
AbortMacro()
PressAndReleaseKey(Fkey)
if IsKeyLockOn("scrolllock") then break end
Sleep(1500)
end
until IsKeyLockOn("scrolllock") -- is ScrollLock LED on?
PressAndReleaseKey("scrolllock") -- turn it off
end
end
UPDATE
local function interruptable_sleep(delay)
local tm = GetRunningTime() + delay
repeat
if IsKeyLockOn("scrolllock") then return true end
local t = tm - GetRunningTime()
if t > 0 then Sleep(math.min(t, 100)) end
until t <= 0
end
function OnEvent(event, arg)
if event=="G_PRESSED" and arg==1 then
repeat
local exit
for _, phase in ipairs{
{macro = "Basicos", sleep_macro = 13000, fkey = "F1", sleep_fkey = 2000},
{macro = "Basicos", sleep_macro = 15000, fkey = "F2", sleep_fkey = 1800},
{macro = "BUFF", sleep_macro = 5000, fkey = "F3", sleep_fkey = 2500},
} do
PlayMacro(phase.macro)
exit = interruptable_sleep(phase.sleep_macro)
AbortMacro()
if exit then break end
PressAndReleaseKey(phase.fkey)
exit = interruptable_sleep(phase.sleep_fkey)
if exit then break end
end
until exit
PressAndReleaseKey("scrolllock")
end
end
UPDATE #2
-- G1 = 2pet
-- G2 = 3pet
local function interruptable_sleep(delay)
local tm = GetRunningTime() + delay
repeat
if IsKeyLockOn("scrolllock") then return true end
local t = tm - GetRunningTime()
if t > 0 then Sleep(math.min(t, 100)) end
until t <= 0
end
function OnEvent(event, arg)
if event=="G_PRESSED" and arg==1 then
repeat
local exit
for _, phase in ipairs{
{macro = "Basicos1", sleep_macro = 16000, },
{macro = "Pick", sleep_macro = 2000, },
{macro = "Pet1", sleep_macro = 2000, },
{macro = "Basicos1", sleep_macro = 16000, },
{macro = "Pick", sleep_macro = 2000, },
{macro = "Pet2", sleep_macro = 2000, },
{macro = "Basicos1", sleep_macro = 16000, },
{macro = "Pick", sleep_macro = 2000, },
} do
PlayMacro(phase.macro)
exit = interruptable_sleep(phase.sleep_macro)
AbortMacro()
if exit then break end
end
until exit
PressAndReleaseKey("scrolllock")
elseif event=="G_PRESSED" and arg==2 then
local loop_ctr = 0
repeat
local exit
loop_ctr = loop_ctr + 1
for _, phase in ipairs{
{macro = "Basicos1", sleep_macro = 16000, skip_on_first_loop = false, },
{macro = "Pick", sleep_macro = 2000, skip_on_first_loop = false, },
{macro = "Pet1", sleep_macro = 2000, skip_on_first_loop = false, },
{macro = "Basicos1", sleep_macro = 16000, skip_on_first_loop = false, },
{macro = "Pick", sleep_macro = 2000, skip_on_first_loop = false, },
{macro = "Pet2", sleep_macro = 2000, skip_on_first_loop = false, },
{macro = "Basicos1", sleep_macro = 16000, skip_on_first_loop = false, },
{macro = "Pick", sleep_macro = 2000, skip_on_first_loop = false, },
{macro = "Pet3", sleep_macro = 2000, skip_on_first_loop = false, },
{macro = "Basicos1", sleep_macro = 16000, skip_on_first_loop = false, },
{macro = "Pick", sleep_macro = 2000, skip_on_first_loop = false, },
} do
if loop_ctr > 1 or not phase.skip_on_first_loop then
PlayMacro(phase.macro)
exit = interruptable_sleep(phase.sleep_macro)
AbortMacro()
if exit then break end
end
end
until exit
PressAndReleaseKey("scrolllock")
end
end