Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Portal turtle
- mon = peripheral.wrap("right")
- bnames = {"Computer","Mobfarm","Farm","","","","","","","","","","","","",""}
- function bdraw(num, str, ison)
- if num > 0 and num < 5 then
- yP = 4
- xp = 12*(num-0)-10
- elseif num > 4 and num < 9 then
- yP = 8
- xp = 12*(num-4)-10
- elseif num > 8 and num < 13 then
- yP = 12
- xp = 12*(num-8)-10
- elseif num > 12 and num < 17 then
- yP = 16
- xp = 12*(num-12)-10
- else
- return
- end
- mon.setCursorPos(xp, yP)
- if ison then
- mon.setBackgroundColor(colors.lime)
- else
- mon.setBackgroundColor(colors.red)
- end
- for i=1,10 do
- mon.write(" ")
- end
- mon.setCursorPos(xp+((10-#str)/2),yP)
- mon.write(str)
- end
- function execute(nmb)
- bdraw(nmb,bnames[nmb],true)
- sleep(1)
- turtle.select(nmb)
- turtle.drop()
- sleep(.5)
- rs.setOutput("back",true)
- sleep(3)
- rs.setOutput("back",false)
- sleep(.5)
- turtle.suck()
- end
- function checkButtons(xPos, yPos)
- if yPos == 4 then
- for num=1,4 do
- if xPos >= (12*(num-0)-10) and xPos <= (12*(num-0)) then
- execute(num)
- end
- end
- elseif yPos == 8 then
- for num=5,8 do
- if xPos >= (12*(num-4)-10) and xPos <= (12*(num-4)) then
- execute(num)
- end
- end
- elseif yPos == 12 then
- for num=9,12 do
- if xPos >= (12*(num-8)-10) and xPos <= (12*(num-8)) then
- execute(num)
- end
- end
- elseif yPos == 16 then
- for num=13,16 do
- if xPos >= (12*(num-12)-10) and xPos <= (12*(num-12)) then
- execute(num)
- end
- end
- end
- end
- function logo()
- mon.setTextColor(colors.cyan)
- mon.setBackgroundColor(colors.gray)
- mon.setCursorPos((x-16)/2,1)
- mon.write("Jo")
- mon.setTextColor(colors.orange)
- mon.write("Ja")
- mon.setTextColor(colors.lightGray)
- mon.write(" Productions")
- end
- function gui()
- x,y = mon.getSize()
- mon.setTextColor(colors.black)
- mon.setBackgroundColor(colors.white)
- for i=1,y do
- mon.setCursorPos(1,i)
- for j=1,x do
- mon.write(" ")
- end
- end
- logo()
- for i=1,16 do
- bdraw(i,bnames[i],false)
- end
- end
- function gesperrt()
- mon.setBackgroundColor(colors.red)
- mon.setTextColor(colors.gray)
- for i=4,y-4 do
- mon.setCursorPos(1,i)
- for j=1,x do
- mon.write(" ")
- end
- end
- mon.setCursorPos((x-8)/2,y/2)
- mon.write("gesperrt")
- end
- while true do
- gui()
- event,_,xPos,yPos = os.pullEvent()
- if event=="monitor_touch" then
- checkButtons(xPos,yPos)
- elseif event=="redstone" then
- if rs.getInput("top") then
- gesperrt()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement