math.randomseed(os.time()*1000000)
dice = math.random(1, 100)
botDice = math.random(1, 100)
playerInput = 67
playerDiff = math.abs(playerInput - dice)
function rollFunction()
if playerInput > dice and playerInput < 101 and playerInput > 0 then
print("Too high, distance from answer is:", playerDiff)
print("Answer is", dice)
elseif playerInput < dice and playerInput < 101 and playerInput > 0 then
print("Too low, distance from answer is", playerDiff)
print("Answer is", dice)
elseif playerInput == dice and playerInput < 101 and playerInput > 0 then
print("No distance")
print("Answer is", dice)
elseif playerInput > 101 or playerInput < 0 then
print("Input a number 1-100")
else
print("Invalid input")
return("nil")
end
end
function botFunction()
botDiff = math.abs(botDice - dice)
if botDice > dice then
print("Bot difference is,", botDiff)
elseif botDice < dice then
print("Bot difference is,", botDiff)
elseif (botDice == dice) and (playerInput ~= dice) then
print("Bot wins automatically")
elseif (botDice == dice) and (playerInput == dice) then
print("Both hit the same number")
end
if (botDiff < playerDiff) then
print("Bot chooses,", botDice)
print("Bot wins")
print("Lose")
elseif (botDiff > playerDiff) then
print("Bot chooses,", botDice)
print("Bot loses")
print("Win")
elseif (botDiff == playerDiff) then
print("Bot chooses,", botDice)
print("Draw")
elseif (bothDiff == playerDiff) then
print("Bot chooses,", botDice)
print("Draw")
else
print("Invalid, nil")
end
end
rollFunction()
botFunction()
To embed this program on your website, copy the following code and paste it into your website's HTML: