RPS = {}
RPS[1] = "Rock"
RPS[2] = "Paper"
RPS[3] = "Scissors"
function RPS()
playerOne = math.random( #RPS )
playerTwo = math.random( #RPS )
if playerOne == playerTwo then
print("It is a tie\n Player One played "..playerOne.."\n Player Two played "..playerTwo..)
elseif playerOne == RPS[1] then
if playerTwo == RPS[2] then
print("Player Two wins\n Player One played "..playerOne.."\n Player Two played "..playerTwo..)
else
print("Player One wins\n Player One played "..playerOne.."\n Player Two played "..playerTwo..)
end
elseif playerOne == RPS[2] then
if playerTwo == RPS[1] then
print("Player One wins\n Player One played "..playerOne.."\n Player Two played "..playerTwo..)
else
print("Player Two wins\n Player One played "..playerOne.."\n Player Two played "..playerTwo..)
end
else
if playerTwo == RPS[1] then
print("Player Two wins\n Player One played "..playerOne.."\n Player Two played "..playerTwo..)
else
print("Player One wins\n Player One played "..playerOne.."\n Player Two played "..playerTwo..)
end
end
end
print(RPS())
不知道这个脚本有什么问题,感谢你们的一些意见。虽然错误在第19行说明:
print("Player One wins\n Player One played "..playerOne.."\n Player Two played "..playerTwo..)
预计会有近期的''
答案 0 :(得分:6)
最后有一个连接调用(..
),但它只有一个参数。删除那个,那应该修复错误。请记住,连接意味着将两个字符串一起添加,它必须有两个参数。
print("Player One wins\n Player One played "..playerOne.."\n Player Two played "..playerTwo)
您还需要更改表名称或函数名称,因为它们存在冲突。