Advertisement
jakendrick3

Jenisis OC V3

Feb 1st, 2017
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.48 KB | None | 0 0
  1. term = require("term")
  2. shell = require("shell")
  3. internet = require("internet")
  4. keyboard = require("keyboard")
  5. event = require("event")
  6. os = require("os")
  7. component = require("component")
  8. modem = component.getPrimary("modem")
  9. gpu = component.getPrimary("gpu")
  10. term = require("term")
  11. colors = require("colors")
  12. fs = require("filesystem")
  13. event = require("event")
  14. textutils = require("serialization")
  15. computer = require("computer")
  16. beep = component.getPrimary("computer")
  17.  
  18. jenisis = {}
  19.  
  20. function jenisis.drawScreen(staticScreen, tableScreen)
  21.   running = true
  22.   rkeyp = true
  23.   cselected = 1
  24.   num = 1
  25.   static = true
  26.  
  27.   while running == true do
  28.     term.clear()
  29.     term.setCursor(1, 1)
  30.    
  31.     rkeyp = true
  32.     isPrint = true
  33.     num = 1
  34.    static = true
  35.     staticNum = 1
  36.     param = "nulll"
  37.  
  38.    while static == true do
  39.      line = staticScreen[staticNum]
  40.      if line ~= nil then
  41.      print(line)
  42.      staticNum = staticNum + 1
  43.      else
  44.      static = false
  45.      end
  46.    end
  47.  
  48.    num = 1
  49.     print(" ")
  50.  
  51.     while isPrint == true do
  52.       line = tableScreen[num]
  53.       if line ~= nil and num ~= cselected then
  54.         print(line)
  55.         num = num + 1
  56.       elseif line ~= nil and num == cselected then
  57.         print("["..line.."]")
  58.         num = num + 1
  59.       else
  60.         isPrint = false
  61.       end
  62.     end
  63.    
  64.     while rkeyp == true do
  65.       ev, p1, p2, key = event.pull(5, "key_down")
  66.       if key == 200 then
  67.         cselected = cselected - 1
  68.         if cselected <= 0 then
  69.           cselected = num - 1
  70.         end
  71.         rkeyp = false
  72.       elseif key == 208 then
  73.         cselected = cselected + 1
  74.         if cselected >= num then
  75.           cselected = 1
  76.         end
  77.         rkeyp = false
  78.       elseif key == 28 then
  79.         return cselected
  80.       elseif key == 15 then
  81.         return 999
  82.       end
  83.     end
  84.   end
  85. end
  86.  
  87. scrX, scrY = gpu.getResolution()
  88.  
  89. term.setCursorPos = term.setCursor
  90. textutils.serialise = textutils.serialize
  91. textutils.unserialise = textutils.unserialize
  92.  
  93. if gpu.maxDepth() > 1 then
  94.   greenbar = 0x00ff00
  95.   redbar = 0xff0000
  96. else
  97.   greenbar = 0xffffff
  98.   redbar = 0xffffff
  99. end
  100.  
  101. modem.open(1024)
  102.  
  103. function jenisis.receive()
  104.   event_ = {event.pull("modem_message")}
  105.  
  106.   return event_[6]
  107. end
  108.  
  109. function jenisis.broadcast(transmes)
  110.   modem.broadcast(1024, transmes)
  111. end
  112.  
  113. function greenBar()
  114.   gpu.setBackground(greenbar)
  115.   term.write(string.rep(" ", scrX))
  116.   gpu.setBackground(0x000000)
  117. end
  118.  
  119. function redBar()
  120.   gpu.setBackground(redbar)
  121.   term.write(string.rep(" ", scrX))
  122.   gpu.setBackground(0x000000)
  123. end
  124.  
  125. function jenisis.inputBar(prompt, hidden)
  126.   term.setCursorPos(1, scrY - 2)
  127.   term.clearLine()
  128.   term.setCursorPos(1, scrY - 1)
  129.   term.clearLine()
  130.  
  131.   term.setCursorPos(1, scrY - 3)
  132.   greenBar()
  133.   term.setCursorPos(1, scrY)
  134.   greenBar()
  135.   term.setCursorPos(1, scrY - 2)
  136.   term.write(prompt)
  137.   term.setCursorPos(1, scrY - 1)
  138.   if hidden then
  139.     info = term.read({}, true, {}, "*")
  140.   else
  141.     info = term.read()
  142.   end
  143.   beep.beep(1000, 0.3)
  144.  
  145.   return info
  146. end
  147.  
  148. function jenisis.errorMes(message, barColor)
  149.   if barColor == "green" then
  150.     printBar = greenBar
  151.   else
  152.     printBar = redBar
  153.   end
  154.  
  155.   term.setCursorPos(1, (scrY / 2) + 2)
  156.   printBar()
  157.   term.setCursorPos(1, (scrY / 2) + 4)
  158.   printBar()
  159.   term.setCursorPos(math.floor((scrX / 2) - (#message / 2)), (scrY / 2) + 3)
  160.   term.write(message)
  161.   beep.beep(1000, 0.3)
  162.   event.pull("key")
  163. end
  164.  
  165. return jenisis
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement