Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local mon = peripheral.wrap("back")
- rednet.open("right")
- local x,y = mon.getSize()
- auto = false
- function gui()
- mon.setTextColor(colors.white)
- mon.setBackgroundColor(colors.gray)
- for i=1,y do
- mon.setCursorPos(1,y)
- for j=1,x do
- mon.write(" ")
- end
- end
- mon.setCursorPos(1,1)
- mon.setBackgroundColor(colors.lightGray)
- for i=0,x do
- mon.write(" ")
- end
- mon.setCursorPos(math.floor(x/2)-6,1)
- mon.setTextColor(colors.orange)
- mon.setTextColor(colors.gray)
- mon.write("Wither-Spawner")
- bdraw(5,3,x-5,y-7,"Start",colors.lime)
- if auto==true then color=colors.green else color=colors.red end
- bdraw(x-6,y-2,x,y,"AUTO",color)
- mon.setBackgroundColor(colors.gray)
- end
- function eventlistener()
- event,side,xPos,yPos = os.pullEvent("monitor_touch")
- if button(5,3,x-5,y-7) then
- start()
- auto = false
- end
- if button(x-6,y-2,x,y) then
- if auto then
- auto = false
- else
- auto = true
- end
- end
- if auto==true then color=colors.green else color=colors.red end
- bdraw(x-6,y-2,x,y,"AUTO",color)
- end
- function start()
- rednet.send(55, "bau")
- rednet.send(58, "bau")
- rednet.send(60, "bau")
- rednet.send(61, "bau")
- sleep(1)
- rednet.send(59, "bau")
- sleep(1)
- rednet.send(57, "bau")
- sleep(1)
- rednet.send(56, "bau")
- end
- function button(x1,y1,x2,y2)
- if xPos<=x2 and xPos>=x1 and yPos<=y2 and yPos>=y1 then
- print("button pressed")
- return true
- else
- print("button not pressed")
- return false
- end
- end
- function bdraw(xp1,yp1,xp2,yp2,txt,col)
- if col==nil then
- mon.setBackgroundColor(colors.lime)
- else
- mon.setBackgroundColor(col)
- end
- mon.setCursorPos(xp1,yp1)
- for i=1,(xp2-xp1) do
- mon.write("-")
- end
- mon.setCursorPos(xp1,yp2)
- for i=1,(xp2-xp1) do
- mon.write("-")
- end
- for i=yp1,yp2 do
- mon.setCursorPos(xp1,i)
- mon.write("|")
- mon.setCursorPos(xp2,i)
- mon.write("|")
- end
- for i=(yp1+1),(yp2-1) do
- mon.setCursorPos((xp1+1),i)
- for j=(xp1+1),(xp2-1) do
- mon.write(" ")
- j = j+1
- end
- i = i+1
- end
- if math.floor(((xp2-xp1)-#txt)/2)==0 then
- xp1 = xp1+1
- end
- mon.setCursorPos(math.floor(((xp2-xp1)-#txt)/2)+xp1,math.floor((yp2-yp1)/2)+yp1)
- print(math.floor(((xp2-xp1)-#txt)/2))
- mon.write(txt)
- end
- function drawText(x,y,txt,tcol,bcol)
- mon.setCursorPos(x,y)
- mon.setTextColor(tcol)
- mon.setBackgroundColor(bcol)
- mon.write(txt)
- end
- function main()
- mon.clear()
- gui()
- eventlistener()
- end
- function autoS()
- for i=1,5 do
- if auto==true then
- bdraw(5,3,x-5,y-7,"Start",colors.red)
- if auto==true then start() end
- for j=1,60 do
- if j>51 then
- drawText(x-6,y-3,"in " .. "0" .. 61-j .. " s",colors.red,colors.gray)
- else
- drawText(x-6,y-3,"in " .. 61-j .. " s",colors.red,colors.gray)
- end
- sleep(1)
- end
- end
- end
- gui()
- end
- parallel.waitForAll(main(), autoS())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement