Hello Guest

Sleep function

  • 10 Replies
  • 683 Views
*

saurabh9371

  • *
  • 3
  • +0/-0
    • View Profile
Sleep function
« on: February 03, 2020, 05:53:37 am »
How can I implement sleep function In order to change speed of dice dynamically and make stop during some profit

I tried os.execute("ping -n " .. tonumber(n+1) .. " localhost > NUL")

But it just flash open and close cmd does nothing
Is there any other way around to wait or sleep function

*

Seuntjie

  • *****
  • 508
  • +14/-2
    • View Profile
Re: Sleep function
« Reply #1 on: February 03, 2020, 07:30:29 am »
you could use the sleep function: sleep(int milliseconds)

*

saurabh9371

  • *
  • 3
  • +0/-0
    • View Profile
Re: Sleep function
« Reply #2 on: February 03, 2020, 09:59:39 am »
It make both unresponsive it's not good for long time sleep

*

Seuntjie

  • *****
  • 508
  • +14/-2
    • View Profile
Re: Sleep function
« Reply #3 on: February 03, 2020, 11:45:00 am »
Any sleep function you use from the programmer mode will have the same effect. the programmer mode wasn't designed with async sleeping in mind.

*

Seuntjie

  • *****
  • 508
  • +14/-2
    • View Profile
Re: Sleep function
« Reply #4 on: February 03, 2020, 11:46:01 am »
Also, why do you want to the bot to sleep? Time or time between bets has no effect on the outcome of your rolls.

*

ProbablyGay

  • **
  • 9
  • +0/-0
    • View Profile
Re: Sleep function
« Reply #5 on: February 16, 2020, 08:09:04 am »
It make both unresponsive it's not good for long time sleep

yes that is true. here is solution for your problem!

Code: [Select]
local clock = os.clock
function sleep(n)  -- seconds
local t0 = clock()
while clock() - t0 <= n do end
end
function dobet()
sleep(5)  -- use whole 5 seconds or any

*

Seuntjie

  • *****
  • 508
  • +14/-2
    • View Profile
Re: Sleep function
« Reply #6 on: February 16, 2020, 08:12:19 am »
the programmer mode has a built in sleep function. You don't need to define your own.

*

ProbablyGay

  • **
  • 9
  • +0/-0
    • View Profile
Re: Sleep function
« Reply #7 on: February 16, 2020, 08:12:54 am »
Also, why do you want to the bot to sleep? Time or time between bets has no effect on the outcome of your rolls.

No. it is useful while bets are in losing streak we get chance to stop bot on time.
Also we can use stoploss for Balance though!

*

Seuntjie

  • *****
  • 508
  • +14/-2
    • View Profile
Re: Sleep function
« Reply #8 on: February 16, 2020, 08:15:32 am »
if you want to the bot to stop on a losing streak, why not use the stop function?

*

ProbablyGay

  • **
  • 9
  • +0/-0
    • View Profile
Re: Sleep function
« Reply #9 on: February 16, 2020, 08:18:27 am »
the programmer mode has a built in sleep function. You don't need to define your own.


inbuilt sleep function HANG DiceBot or sometimes has to close bot after waiting more than 15 minutes for me it doesn't continue betting

*

Seuntjie

  • *****
  • 508
  • +14/-2
    • View Profile
Re: Sleep function
« Reply #10 on: February 16, 2020, 08:25:04 am »
The sleep function that you posted also hangs the UI thread, so it should have the exact same effect.