name = "caleb"
botName = "DummyBot"
answer = "gun!"
function rollFunction()
math.randomseed(os.time())
dice = math.random(1, 3)
if dice == 1 then
return("Rock!")
elseif dice == 2 then
return("Paper!")
elseif dice == 3 then
return("Scissors!")
else
return("Gun!")
end
end
function outcomeFunction(answer)
correctedString = string.lower(answer)
if correctedString == "rock!" and dice == 2 then
return("YOU LOSE!")
elseif correctedString == "rock!" and dice == 3 then
return("YOU WIN!")
elseif correctedString == "rock!" and dice == 1 then
return("DRAW!")
elseif correctedString == "paper!" and dice == 1 then
return("YOU WIN!")
elseif correctedString == "paper!" and dice == 2 then
return("DRAW!")
elseif correctedString == "paper!" and dice == 3 then
return("YOU LOSE")
elseif correctedString == "scissors!" and dice == 2 then
return("YOU WIN!")
elseif correctedString == "scissors!" and dice == 1 then
return("YOU LOSE!")
elseif correctedString == "scissors!" and dice == 3 then
return("DRAW!")
elseif correctedString == "gun!" then
return("YOU AUTOMATICALLY WIN FOR BRINGING A GUN!!!")
else
return("INSERT A VALID CHOICE!!!")
end
end
print(name, "chooses,", answer)
roll = rollFunction()
print(botName, "chooses,", roll)
outcome = outcomeFunction(answer)
print(outcome)
To embed this program on your website, copy the following code and paste it into your website's HTML: