Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- monitor=peripheral.wrap("top")
- rednet.open("right")
- monitor.setTextScale(2)
- portals={
- {"Tower",colors.blue,1},
- {"Thaumcraft",colors.purple,2}
- }
- button={
- {"<",1,6,"siteL"},
- {">",12,6,"siteR"},
- {"Set",6,6,"set"}
- }
- function clear()
- monitor.clear()
- monitor.setCursorPos(1,1)
- monitor.setBackgroundColor(colors.black)
- monitor.setTextColor(colors.white)
- end
- function length(txt)
- counter=0
- for i=1, #txt do
- counter=counter+1
- end
- return counter
- end
- function site(tb)
- clear()
- monitor.setTextColor(colors.lightGray)
- monitor.setCursorPos(5,1)
- monitor.write("Portal")
- aLaenge=length(portals[tb][1])
- bLaenge=aLaenge / 2
- cursor=8-bLaenge
- monitor.setCursorPos(cursor,3)
- monitor.setTextColor(portals[tb][2])
- abc = tonumber(aCount)
- if tb == abc then
- monitor.setBackgroundColor(colors.gray)
- end
- monitor.write(portals[tb][1])
- monitor.setBackgroundColor(colors.black)
- for i=1, #button do
- monitor.setTextColor(colors.gray)
- monitor.setCursorPos(button[i][2],button[i][3])
- monitor.write("["..button[i][1].."]")
- end
- end
- function fileIn(ins)
- a=fs.open("Portal","w")
- a.write(ins)
- a.close()
- end
- function fileOut()
- a=fs.open("Portal","r")
- b=a.readAll()
- a.close()
- return b
- end
- bCount=1
- while true do
- cCount=0
- for i=1, #portals do
- cCount=cCount+1
- end
- aCount=fileOut()
- site(bCount)
- event={os.pullEvent()}
- if event[1]=="monitor_touch"then
- for i=1, #button do
- anfang=button[i][2]
- ende=anfang+length(button[i][1])+1
- if event[4] == button[i][3] and event[3] >= anfang and event[3] <= ende then
- if button[i][4] == "set" then
- rednet.send(87,aCount)
- sleep(0.5)
- rednet.send(87,"out")
- fileIn(bCount)
- sleep(0.5)
- rednet.send(87,bCount)
- sleep(0.5)
- rednet.send(87,"in")
- elseif button[i][4] == "siteL" then
- if bCount > 1 then
- bCount = bCount - 1
- end
- elseif button[i][4] == "siteR" then
- if bCount < cCount then
- bCount = bCount + 1
- end
- end
- else
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement