Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- m = peripheral.wrap("top")
- modem = peripheral.wrap("right")
- m.clear()
- buttons = {}
- --------------------------------------------------
- -- button creation
- --------------------------------------------------
- -- Directional button color
- dirColor = colors.red
- -- Inventory button color
- invColor = colors.white
- ---------------------------------
- --Directional buttons
- ---------------------------------
- -- fbut (forward)
- fxMin = 23
- fxSize = 7
- fxMax = fxMin + fxSize - 1
- fyMin = 6
- fySize = 4
- fyMax = fyMin + fySize - 1
- fbut = window.create(m,fxMin,fyMin,fxSize,fySize)
- fbut.setBackgroundColor(dirColor)
- fbut.restoreCursor()
- fbut.redraw()
- fbut.setCursorPos(1,2)
- fbut.write("forward")
- -- bbut (backwards)
- bxMin = 23
- bxSize = 7
- bxMax = bxMin + bxSize - 1
- byMin = 12
- bySize = 4
- byMax = byMin + bySize - 1
- bbut = window.create(m,bxMin,byMin,bxSize,bySize)
- bbut.setBackgroundColor(dirColor)
- bbut.redraw()
- bbut.restoreCursor()
- bbut.setCursorPos(1,2)
- bbut.write(" back ")
- bbut.redraw()
- -- lbut (left)
- lxMin = 19
- lxSize = 7
- lxMax = lxMin + lxSize - 1
- lyMin = 9
- lySize = 4
- lyMax = lyMin + lySize - 1
- lbut = window.create(m,lxMin,lyMin,lxSize,lySize)
- lbut.setBackgroundColor(dirColor)
- lbut.redraw()
- lbut.setCursorPos(1,2)
- lbut.write(" left ")
- -- rbut (right)
- rxMin = 27
- rxSize = 7
- rxMax = rxMin + rxSize - 1
- ryMin = 9
- rySize = 4
- ryMax = ryMin + rySize - 1
- rbut = window.create(m,rxMin,ryMin,rxSize,rySize)
- rbut.setBackgroundColor(dirColor)
- rbut.redraw()
- rbut.setCursorPos(1,2)
- rbut.write(" right ")
- -- ubut (up)
- uxMin = 36
- uxSize = 2
- uxMax = uxMin + uxSize - 1
- uyMin = 7
- uySize = 3
- uyMax = uyMin + uySize - 1
- ubut = window.create(m,uxMin,uyMin,uxSize,uySize)
- ubut.setBackgroundColor(dirColor)
- ubut.restoreCursor()
- for i = 1, uySize do
- ubut.setCursorPos(1,i)
- ubut.write(" ")
- end
- m.setCursorPos(36,6)
- m.write("up")
- -- dbut (down)
- dxMin = 36
- dxSize = 2
- dxMax = dxMin + dxSize - 1
- dyMin = 11
- dySize = 3
- dyMax = dyMin + dySize - 1
- dbut = window.create(m,dxMin,dyMin,dxSize,dySize)
- dbut.setBackgroundColor(dirColor)
- dbut.restoreCursor()
- for i = 1, dySize do
- dbut.setCursorPos(1,i)
- dbut.write(" ")
- end
- m.setCursorPos(35,14)
- m.write("down")
- ----------------------------
- --Inventory Buttons
- ----------------------------
- ixMin = 1
- ixSize = 14
- ixMax = ixMin + ixSize - 1
- iySize = 1
- -- i1
- iyMin = 2
- i1 = window.create(m,ixMin,iyMin,ixSize,iySize)
- -- input listener
- while(true) do
- event, side, xpos, ypos = os.pullEvent("monitor_touch")
- write(xpos .. ", " .. ypos.."\n")
- rednet.open("right")
- if ( xpos >= fxMin and xpos <= fxMax and
- ypos >= fyMin and ypos <= fyMax )then
- rednet.broadcast("forward")
- elseif ( xpos >= bxMin and xpos <= bxMax and
- ypos >= byMin and ypos <= byMax )then
- rednet.broadcast("back")
- elseif ( xpos >= lxMin and xpos <= lxMax and
- ypos >= lyMin and ypos <= lyMax )then
- rednet.broadcast("left")
- elseif ( xpos >= rxMin and xpos <= rxMax and
- ypos >= ryMin and ypos <= ryMax )then
- rednet.broadcast("right")
- elseif ( xpos >= uxMin and xpos <= uxMax and
- ypos >= uyMin and ypos <= uyMax )then
- rednet.broadcast("up")
- elseif ( xpos >= dxMin and xpos <= dxMax and
- ypos >= dyMin and ypos <= dyMax )then
- rednet.broadcast("down")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment