Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function callScripts()
- dofile("Variables.lua")
- dofile("Function.lua")
- end
- callScripts()
- clear()
- prepareBoard()
- printBoard()
- getInput()
- while true do
- end
- --Begin Variables--
- --Random Variables
- player=1
- --Table declaration
- --Board Table
- --0 netrual, 1 x, 2 o
- board = {}
- board[1] = 0
- board[2] = 0
- board[3] = 0
- board[4] = 0
- board[5] = 0
- board[6] = 0
- board[7] = 0
- board[8] = 0
- board[9] = 0
- --Board String Table
- boardString = {}
- function clear()
- print("")
- print("")
- print("")
- print("")
- print("")
- print("")
- print("")
- print("")
- print("")
- print("")
- print("")
- print("")
- print("")
- print("")
- print("")
- end
- --Begin Functions--
- function clear()
- print("")
- print("")
- print("")
- print("")
- print("")
- print("")
- print("")
- print("")
- print("")
- print("")
- print("")
- print("")
- print("")
- print("")
- print("")
- end
- function getInput()
- if player==1 then
- print("Player 1, type the square you would like to fill. (Ex. 1-9)")
- io.read = player1input
- for i = 1,9 do
- if tostring(i) == player1input then
- if board[i] == 0 then
- board[i] = 1
- player = 2
- elseif board[i] > 0 then
- print("This square has already been chosen. Please choose another.")
- end
- end
- end
- end
- if player==2 then
- print("Player 2, type the sqaure you would like to fill. (Ex. 1-9)")
- io.read = player2input
- for i = 1,9 do
- if tostring(i) == player2input then
- if board[i] == 0 then
- board[i] = 1
- player = 1
- elseif board[i] > 0 then
- print("This square has already been chosen. Please choose another.")
- end
- end
- end
- end
- end
- function prepareBoard()
- for i = 1,9 do
- if board[i] == 0 then
- boardString[i] = " "
- elseif board[i] == 1 then
- boardString[i] = "X"
- elseif board[i] == 2 then
- boardString[i] = "O"
- end
- end
- end
- function printBoard()
- print(boardString[1].."|"..boardString[2].."|"..boardString[3])
- print(boardString[4].."|"..boardString[5].."|"..boardString[6])
- print(boardString[7].."|"..boardString[8].."|"..boardString[9])
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement