Hello Guest

Multi dobet() functions in a script

  • 1 Replies
  • 108 Views
*

Anakyl

  • **
  • 9
  • +1/-0
    • View Profile
Multi dobet() functions in a script
« on: April 18, 2019, 06:52:33 am »
Hello,

Is it possible to use multi dobet() functions in a script?
Example:

Code: [Select]
function dobet()
roundprofit += currentprofit
if roundprofit > maxprofit then maxprofit = roundprofit
percentprofit = round( ( ( (maxprofit - roundprofit) / maxprofit) * 100), 2 )

if percentprofit < 5 then -- Safe Mode
function dobet()
do something
end
else -- Panic Mode
function dobet()
do something
end
end
end

*

Seuntjie

  • *****
  • 279
  • +2/-2
    • View Profile
Re: Multi dobet() functions in a script
« Reply #1 on: April 18, 2019, 07:43:53 am »
Two things. First: If you are in a room and there's another Anakyl in the same room, I stand outside and say "Anakyl, come out", how do you know which one should come out? So how would the bot know which dobet function you're talking about if they have the same name?
Second: You cannot nest functions. but your approach is correct.

Code: [Select]
function dobet()
roundprofit += currentprofit
if roundprofit > maxprofit then maxprofit = roundprofit
percentprofit = round( ( ( (maxprofit - roundprofit) / maxprofit) * 100), 2 )

if percentprofit < 5 then -- Safe Mode

--do something

else -- Panic Mode

--do something else

end
end

no need to create another dobet function.

If you want to work in functions, see https://forum.seuntjie.com/index.php?topic=2.msg963#msg963