Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("button")
- local mainMonitor = "top"
- GamePanel = peripheral.wrap(mainMonitor)
- GamePanel.clear()
- ControlPanel = peripheral.wrap("right")
- ControlPanel.clear()
- local xc, yc = ControlPanel.getSize()
- function writeMessage(message)
- ControlPanel.setCursorPos(math.floor((xc - string.len(message))/2+1),yc/2 + 1)
- ControlPanel.write(message)
- end
- writeMessage("CrossTurn")
- local xo, yo = GamePanel.getSize()
- print("Width: "..xo)
- print("Height: "..yo)
- local width = math.floor((xo-2)/3)
- local height = math.floor((yo-2)/3)
- print("Box width: "..width)
- print("Box height: "..height)
- sleep(0)
- function fx(params)
- local x = params["x"]
- local y = params["y"]
- print("Field at "..x..","..y.." was clicked")
- end
- --fx setup
- --0,0 1,0 2,0
- --0,1 1,1 2,1
- --0,2 1,2 2,2
- function fillTable()
- for x = 0,2 do
- for y = 0,2 do
- local xPos = x * width + x + 1
- local yPos = y * height + y + 1
- print("Drawing button "..x..","..y.." at "..xPos..","..yPos.."...")
- button.setTable(x..y, fx, {["x"] = x, ["y"] = y}, xPos, xPos + width - 1, yPos, yPos + height - 1)
- end
- end
- button.screen()
- end
- function getClick()
- event,side,x,y = os.pullEvent("monitor_touch")
- if side == mainMonitor then
- button.checkxy(x,y)
- end
- end
- fillTable()
- --button.heading("TicTacToe")
- while true do
- getClick()
- end
Add Comment
Please, Sign In to add comment