Hello Guest

Aritmetic on a nill value

  • 3 Replies
  • 31 Views
*

al1mert

  • *
  • 4
  • +0/-0
    • View Profile
Aritmetic on a nill value
« on: April 12, 2019, 08:20:17 pm »
Code: [Select]
profit = 0.000001

--later in the code

profit = (profit + previousbet/1.1)

error code
22: attempt to perform arithmetic on global 'profit' (a nil value)

I tried using temp values but it didnt work.

*

Seuntjie

  • *****
  • 247
  • +2/-2
    • View Profile
Re: Aritmetic on a nill value
« Reply #1 on: April 12, 2019, 08:45:07 pm »
Code: [Select]
profit = 0.000001

--later in the code

profit = (profit + previousbet/1.1)

error code
22: attempt to perform arithmetic on global 'profit' (a nil value)

I tried using temp values but it didnt work.

profit is a system variable, i'd recommend not assigning a value to it.
Make sure the variable you're trying to use does have a value when you use it. If you assign a value for the first time inside of an if, it might be used somewhere else before the conditions for that if has been met.

Also, just check the spelling for the internal variables in the variables box in the bot. It's difficult to say anything more without seeing more of your script

*

al1mert

  • *
  • 4
  • +0/-0
    • View Profile
Re: Aritmetic on a nill value
« Reply #2 on: April 12, 2019, 09:01:28 pm »
Code: [Select]
profit = 0.000001

--later in the code

profit = (profit + previousbet/1.1)

error code
22: attempt to perform arithmetic on global 'profit' (a nil value)

I tried using temp values but it didnt work.

profit is a system variable, i'd recommend not assigning a value to it.
Make sure the variable you're trying to use does have a value when you use it. If you assign a value for the first time inside of an if, it might be used somewhere else before the conditions for that if has been met.

Also, just check the spelling for the internal variables in the variables box in the bot. It's difficult to say anything more without seeing more of your script

Oh sorry, profit is not actually what i named my variable. It is just a pseudo code. I am sure it is not a spelling error or something. Rest of the code works perfectly.
Its only I cant modify myProfit.

Code: [Select]
myProfit = -0.00000001

function dobet()


myProfit = profit


if currentstreak < -5 then
myProfit = myProfit + (previousbet/1.15)
end

end


I can use the value like this: a = ((myProfit/10) * -1 ), but I cant modify it. Thanks for the quick answer.
I can post the full code but only thing that is not working here is these line of codes that I recently added.

*

al1mert

  • *
  • 4
  • +0/-0
    • View Profile
Re: Aritmetic on a nill value
« Reply #3 on: April 12, 2019, 10:49:16 pm »
I solved it by using a temp value.
Code: [Select]
myProfitTemp = myProfit;
myProfitTemp = MyProfitTemp + previousbet (or whatever you want to do)

I tried using a temp value before but it didnt work because i tried like this:
Code: [Select]
myProfitTemp = myProfit + previousbet