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