Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Portal turtle
- mon = peripheral.wrap("back")
- bnames = {"Oak","","","Rubber","","","","","Wheed","Carrot","Potato","","","",""}
- function bdraw(num, str, ison)
- if num > 0 and num < 5 then
- yP = 3
- xp = 12*(num-0)-10
- elseif num > 4 and num < 9 then
- yP = 6
- xp = 12*(num-4)-10
- elseif num > 8 and num < 13 then
- yP = 9
- xp = 12*(num-8)-10
- elseif num > 12 and num < 17 then
- yP = 12
- 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 midwrite(txt, yP)
- x,y = mon.getSize()
- xP = (x-#txt)/2
- mon.setCursorPos(xP,yP)
- mon.write(txt)
- end
- function execute(nmb)
- bdraw(nmb,bnames[nmb],true)
- rs.setBundledOutput("left",0)
- color = 1
- for i=1,nmb-1 do
- color = color*2
- end
- rs.setBundledOutput("left",color)
- mon.setBackgroundColor(colors.gray)
- for j=5,y-4 do
- mon.setCursorPos(5,j)
- for k=5,x-4 do
- mon.write(" ")
- end
- end
- mon.setTextColor(colors.lightGray)
- midwrite("Es wird "..bnames[nmb].." angebaut",y-6)
- mon.setTextColor(colors.gray)
- for i=1,100 do
- pos = ((x-4-5-2)/100)*i
- mon.setCursorPos(6,y-5)
- mon.setBackgroundColor(colors.lime)
- for j=1,pos do
- mon.write(" ")
- end
- mon.setBackgroundColor(colors.white)
- mon.setTextColor(colors.lightGray)
- mon.setBackgroundColor(colors.gray)
- midwrite(i.."%",y-5)
- sleep(0.1)
- end
- rs.setBundledOutput("left",colors.black)
- sleep(.5)
- end
- function checkButtons(xPos, yPos)
- if yPos == 3 then
- for num=1,4 do
- if xPos >= (12*(num-0)-10) and xPos <= (12*(num-0)) then
- execute(num)
- end
- end
- elseif yPos == 6 then
- for num=5,8 do
- if xPos >= (12*(num-4)-10) and xPos <= (12*(num-4)) then
- execute(num)
- end
- end
- elseif yPos == 9 then
- for num=9,12 do
- if xPos >= (12*(num-8)-10) and xPos <= (12*(num-8)) then
- execute(num)
- end
- end
- elseif yPos == 12 then
- for num=13,15 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,15 do
- bdraw(i,bnames[i],false)
- end
- end
- while true do
- gui()
- event,_,xPos,yPos = os.pullEvent("monitor_touch")
- print("touched!")
- checkButtons(xPos,yPos)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement