1

I've got a basic auto clicking script that I'd like to add a print function to that tells me the total sleep. I am incredibly new to LUA and what I've tried after reading a couple WIKIs hasn't worked. Everything I try I get "attempt to call a nil value".

EnablePrimaryMouseButtonEvents(true);
function OnEvent(event, arg)
if IsKeyLockOn("capslock")then
if IsMouseButtonPressed(5)then
   repeat
   PressMouseButton(1)
   Sleep(math.random (51, 55))
   ReleaseMouseButton(1)
   Sleep (math.random(526, 530))
   until not IsMouseButtonPressed(5)
end
end
end

I'd like for each action to print to console the total sleep before it repeats. So for example it would output "577" if Sleep 51 and Sleep 526 were the math selections in the randomization. Is this possible?

1 Answer 1

1

You should use OutputLogMessage instead of print.
You will see the output in the bottom window of LGS/GHUB Lua script editor.

EnablePrimaryMouseButtonEvents(true);
function OnEvent(event, arg)
 if IsKeyLockOn("capslock")then
  if IsMouseButtonPressed(5)then
   repeat
    PressMouseButton(1)
    local w1 = math.random (51, 55)
    Sleep(w1)
    ReleaseMouseButton(1)
    local w2 = math.random(526, 530)
    Sleep (w2)
    OutputLogMessage("Total sleep: "..tostring(w1+w2).."\n")
   until not IsMouseButtonPressed(5)
  end
 end
end
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! I didn't know about the OutputLogMessage, that's a good one to know. I appreciate the quick response.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.