-2

So my script currently stops on conditions

if profit >= 0.1 then
    stop()
end

i want to implement this code into mine so after the target satified it will sleep for 30 secs and then restart my dobet function

if found this

function sleep()
t0 = os.clock()
while os.clock() - t0 <= n do
      end

but i cant find a way to restart after sleep and restart my dobet() function

my code sample

https://pastebin.com/2Vi2iC81

2 Answers 2

0

try:

local function sleep(seconds)
    local time = os.time() + seconds
    repeat until os.time() > time
end

chance = 49.5
multiplier = 2
basebet = 0.00000010
bethigh = false
​
function dobet()
    while true do
        if profit >= 0.1 then
            break
        end
    
        if win then
            nextbet = basebet
        else
            nextbet = previousbet * multiplier
        end
        sleep(30)
    end
end

this should fix it, let me know if it does not fix it.

Sign up to request clarification or add additional context in comments.

1 Comment

yeah it made my system crash
-2

You can use goto to re-execute a code.

Example:

-- Use local variable instead using global variable, the global method can slowdown your script

local function sleep(s) -- Define a sleep function 
  local ntime = os.time() + s
  repeat until os.time() > ntime
end


-- Setup
local chance = 49.5
local multiplier = 2
local basebet = .00000010
local bethigh = false


-- Main field
local function dobet()
  if profit >= .1 then
    stop()
    
    sleep(30) -- Sleep/Wait for 30 seconds
    goto restart -- Go back to "restart" point
  end

  if win then
    nextbet = basebet

    sleep(30) -- Doing the same thing
    goto restart
  else
    nextbet = previousbet * multiplier

    sleep(30)
    goto restart
  end
end

::restart:: -- Define a "goto" point
dobet()

You can also use the factorial function method to re-run the function inside the function itself

local n = 0

local function printHelloWorld()
  if n >= 10 then
    return -- Stop the function basically
  else
    print('Hello World!')

    n = n + 1
    printHelloWorld()
  end
end

printHelloWorld()

References:

4 Comments

im getting a no visible label restart at line 13
That's weird... You can use the factorial method above as an alternative to "goto"
i seen that alot more complicated then restart lol can you explain how this would go with my code
This is a prime example of when to not use goto. You should use a tail call return dobet() to restart the "dobet" function - or a while/repeat-until loop - instead.

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.