Hello Guest

Resetting "profit" back to zero in "Stat"

  • 3 Replies
  • 3003 Views
*

jeff4610

  • **
  • 6
  • +0/-0
    • View Profile
Resetting "profit" back to zero in "Stat"
« on: March 15, 2018, 08:42:44 pm »
Hi  Seuntjie
 
I  want to add a line in programmer mode to reset "profit" back to zero in "stat" when it reaches a certain amount, say 0.01000000.

How to write the code?

The ,main idea is:
If profit > 0.01000000 then
  profit = 0.0000000
0


Thank you for making this forum!
« Last Edit: March 15, 2018, 08:45:00 pm by jeff4610 »

*

Seuntjie

  • *****
  • 593
  • +17/-3
    • View Profile
Re: Resetting "profit" back to zero in "Stat"
« Reply #1 on: March 15, 2018, 11:20:59 pm »
Hi  Seuntjie
 
I  want to add a line in programmer mode to reset "profit" back to zero in "stat" when it reaches a certain amount, say 0.01000000.

How to write the code?

The ,main idea is:
If profit > 0.01000000 then
  profit = 0.0000000
0


Thank you for making this forum!

If you take a look at the steemit tutorials (specifically  https://steemit.com/dicebot/@seuntjie/dicebot-programmer-mode-tutorial-1-1-variables and https://steemit.com/seuntjie/@seuntjie/dicebot-programmer-mode-tutorial-01-2-functions ) You'll see that profit is a readonly variable. Meaning while the program will allow you to set the value, DiceBot will ignore your new value.

There is no way to reset only the profit stat. You can use the resetstats function (see the second tutorial I linked) to rest all stats, or you will have to manually track your profit and use a modified variable when you reset it, for example:

Code: [Select]
lastprofit = profit
function dobet()
If profit-lastprofit  > 0.01000000 then
  lastprofit =profit
end
end

and wherever you would normally use just profit in a check, use profit-lastprofit instead.

*

jeff4610

  • **
  • 6
  • +0/-0
    • View Profile
Re: Resetting "profit" back to zero in "Stat"
« Reply #2 on: March 16, 2018, 12:41:18 am »
Hi  Seuntjie

Thank you for your prompt reply. Can you also show me the code to reset all stats if profit > 0.01000000?

I have very limited knowledge in programming.


« Last Edit: March 16, 2018, 12:45:17 am by jeff4610 »

*

HCP

  • *
  • 2
  • +2/-0
  • <insert witty comment here>
    • View Profile
Re: Resetting "profit" back to zero in "Stat"
« Reply #3 on: March 16, 2018, 04:48:06 am »
Thank you for your prompt reply. Can you also show me the code to reset all stats if profit > 0.01000000?

As he stated... look in the second link... it has a list of all the custom bot functions that are provided in programmer mode. You'll find the following:

resetstats() Returns: Void. Resets the session stats for the bot. Takes effect in programmer mode after next bet.

So all you need to do is check if your condition is true, and if so, call resetstats():
Code: [Select]
if profit > 0.01 then
  resetstats()
end