Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- monitor = peripheral.wrap('top')
- modem = peripheral.wrap('bottom')
- modem.open(32)
- --draws a box of x2-x1/y2-y1 pixels at given coordinates, corner at x1,y1
- function drawBox(x1,x2,y1,y2,terminal,c)
- prevcolor = terminal.getBackgroundColor()
- for i = x1, x2 do
- for j= y1, y2 do
- terminal.setBackgroundColor(c)
- terminal.setCursorPos(i,j)
- terminal.write(" ")
- end
- end
- terminal.setBackgroundColor(prevcolor)
- end
- --draws a plus sign
- function drawPlus(x1,x2,y1,y2,terminal,c)
- prevcolor = terminal.getBackgroundColor()
- --odd
- if (math.mod(x2-x1,2) == 0) or (math.mod(y2-y1,2) == 0) then
- middleX = (x2+x1)/2
- middleY = (y2+y1)/2
- --horizontal
- for i=x1,x2 do
- terminal.setBackgroundColor(c)
- terminal.setCursorPos(i,middleY)
- terminal.write(" ")
- end
- --vertical
- for j=y1,y2 do
- terminal.setBackgroundColor(c)
- terminal.setCursorPos(middleX,j)
- terminal.write(" ")
- end
- --even
- else if (math.mod(x2-x1,2) ~= 0) or (math.mod(y2-y1,2) ~= 0) then
- middleleft,middleright = x2-1,x2/2
- middlebottom,middlettop = y2-1,y2/2
- --vertical
- for i=middleleft,middleright do
- for j=y1,y2 do
- terminal.setBackgroundColor(c)
- terminal.setCursorPos(i,j)
- terminal.write(" ")
- end
- end
- --horizontal
- for k=x1,x2 do
- for l=middleleft,middleright do
- terminal.setBackgroundColor(c)
- terminal.setCursorPos(k,l)
- terminal.write(" ")
- end
- end
- else
- return print("not a square")
- end
- end
- terminal.setBackgroundColor(prevcolor)
- end
- --draws a minus sign
- function drawMinus(x1,x2,y1,y2,terminal,c)
- prevcolor = terminal.getBackgroundColor()
- --odd
- if (math.mod(x2-x1,2) == 0) or (math.mod(y2-y1,2) == 0) then
- middleY = (y1+y2)/2
- middleX = (x1+x2)/2
- for i=x1,x2 do
- terminal.setBackgroundColor(c)
- terminal.setCursorPos(i,middleY)
- terminal.write(" ")
- end
- --even
- elseif (math.mod(x2-x1,2) ~= 0) or (math.mod(y2-y1,2) ~= 0) then
- bottomY,topY = y2-1,y2/2
- for i=x1,x2 do
- for j=topY,bottomY do
- terminal.setBackgroundColor(c)
- terminal.setCursorPos(i,j)
- terminal.write(" ")
- end
- end
- else
- print("uh oh, something went wrong UwU")
- end
- terminal.setBackgroundColor(prevcolor)
- end
- --sets up monitors
- function monitorSetup(terminal,linhas)
- terminal.setBackgroundColor(colors.black)
- terminal.setTextColor(colors.white)
- terminal.clear()
- terminal.setTextScale(1)
- for i=1, 4 do
- terminal.setCursorPos(1,i)
- terminal.write(linhas[i])
- end
- drawBox(2,7,8,11,terminal,colors.red)
- terminal.setCursorPos(2,6)
- terminal.write("TOGGLE")
- terminal.setCursorPos(2,7)
- terminal.write("CIRCLE")
- terminal.setCursorPos(11,6)
- terminal.write("CRAFT")
- terminal.setCursorPos(11,7)
- terminal.write("NUMBER:0")
- --botao de +
- drawBox(11,13,8,10,terminal,colors.red)
- drawPlus(11,13,8,10,terminal,colors.white)
- --botao de -
- drawBox(16,18,8,10,terminal,colors.red)
- drawMinus(16,18,8,10,terminal,colors.white)
- end
- --toggle circle area check
- function checkToggle(x,y)
- clickInButton = false
- for i=2,7 do
- for j=8,11 do
- if i==x and j==y then
- clickInButton = true
- end
- end
- end
- return clickInButton
- end
- monitorlines = {"Uphyxes Inv Tower","Eziveus' Spec Compulsion","Strigeor's High Binding","Sevira's Perma Confinement"}
- --monitorlines2 = {"Abra's Norm/Open/Fort Conj","Aviar's Circle","Ophyx' Calling","Fatma's Incent Attract"}
- --monitorlines3 = {"Abra's Com/Open Com Conj","Ihagan's Enthrallment","Hedyrin's Lure","Xeovrenth Adjure"}
- --monitorlines4 = {"Ronazas Contact","","",""}
- while true do
- monitorSetup(monitor,monitorlines)
- repeat
- e, s, cX, cY = os.pullEvent("monitor_touch")
- until e ~= nil
- if checkToggle(cX,cY) then
- modem.transmit(1,32,"potato")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement