Advertisement
Guest User

startup

a guest
Jul 23rd, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.30 KB | None | 0 0
  1. monitor=peripheral.wrap("top")
  2. rednet.open("right")
  3. monitor.setTextScale(2)
  4.  
  5.  
  6. portals={
  7.          {"Tower",colors.blue,1},
  8.          {"Thaumcraft",colors.purple,2}
  9.         }
  10.        
  11. button={
  12.         {"<",1,6,"siteL"},
  13.         {">",12,6,"siteR"},
  14.         {"Set",6,6,"set"}
  15.        }  
  16.  
  17.  
  18. function clear()
  19.   monitor.clear()
  20.   monitor.setCursorPos(1,1)
  21.   monitor.setBackgroundColor(colors.black)
  22.   monitor.setTextColor(colors.white)
  23. end
  24.  
  25. function length(txt)
  26.   counter=0
  27.   for i=1, #txt do
  28.     counter=counter+1
  29.   end
  30.   return counter
  31. end
  32.  
  33. function site(tb)
  34.   clear()
  35.   monitor.setTextColor(colors.lightGray)
  36.   monitor.setCursorPos(5,1)
  37.   monitor.write("Portal")
  38.   aLaenge=length(portals[tb][1])
  39.   bLaenge=aLaenge / 2
  40.   cursor=8-bLaenge
  41.   monitor.setCursorPos(cursor,3)
  42.   monitor.setTextColor(portals[tb][2])
  43.   abc = tonumber(aCount)
  44.   if tb == abc then
  45.     monitor.setBackgroundColor(colors.gray)
  46.   end
  47.   monitor.write(portals[tb][1])
  48.   monitor.setBackgroundColor(colors.black)
  49.  
  50.   for i=1, #button do
  51.     monitor.setTextColor(colors.gray)
  52.     monitor.setCursorPos(button[i][2],button[i][3])
  53.     monitor.write("["..button[i][1].."]")
  54.   end
  55. end
  56.  
  57. function fileIn(ins)
  58.   a=fs.open("Portal","w")
  59.   a.write(ins)
  60.   a.close()
  61. end
  62.  
  63. function fileOut()
  64.   a=fs.open("Portal","r")
  65.   b=a.readAll()
  66.   a.close()
  67.   return b
  68. end
  69.  
  70. bCount=1
  71. while true do
  72.   cCount=0
  73.  
  74.   for i=1, #portals do
  75.     cCount=cCount+1
  76.   end
  77.  
  78.   aCount=fileOut()
  79.   site(bCount)
  80.  
  81.   event={os.pullEvent()}
  82.  
  83.   if event[1]=="monitor_touch"then
  84.    
  85.     for i=1, #button do
  86.    
  87.       anfang=button[i][2]
  88.       ende=anfang+length(button[i][1])+1
  89.      
  90.       if event[4] == button[i][3] and event[3] >= anfang and event[3] <= ende then
  91.         if button[i][4] == "set" then
  92.           rednet.send(87,aCount)
  93.           sleep(0.5)
  94.           rednet.send(87,"out")
  95.           fileIn(bCount)
  96.           sleep(0.5)
  97.           rednet.send(87,bCount)
  98.           sleep(0.5)
  99.           rednet.send(87,"in")
  100.         elseif button[i][4] == "siteL" then
  101.           if bCount > 1 then
  102.             bCount = bCount - 1
  103.           end
  104.         elseif button[i][4] == "siteR" then
  105.           if bCount < cCount then
  106.             bCount = bCount + 1
  107.           end
  108.         end
  109.         else
  110.       end
  111.     end
  112.   end
  113. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement