Advertisement
goldfiction

glasstest2

Aug 10th, 2023 (edited)
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 59.91 KB | None | 0 0
  1. --0.5.2 by UNOBTANIUM 09.06.2015
  2. local site = {}
  3. local screen = {}
  4. local selected = 1
  5. local selectedObj = 1
  6. local z = 1
  7. local mode = "mainmenu"
  8. local errorText = nil
  9. local w,h = term.getSize()
  10. w = w + 1
  11. local updateInterval = 2
  12. local delay = os.startTimer(0.5)
  13. local colorName = {colors.white, colors.orange, colors.magenta, colors.lightBlue, colors.yellow, colors.lime, colors.pink, colors.lightGray, colors.cyan, colors.purple, colors.blue, colors.brown, colors.green, colors.red, colors.black}
  14. local colorHex = {0xFFFFFF,0xFF8800,0xFF8CFF,0x00FFFF,0xFFF700,0x00FF11,0xF7B5DE,0xBFBFBF,0x65A1D6,0xAF56B3,0x0000FF,0x754302,0x004000,0xFF0000,0x000000}
  15.  
  16. function findAndWrap(devType)
  17. local devices = peripheral.getNames()
  18. for id, devName in pairs(devices) do
  19. if peripheral.getType(devName) == devType then
  20. return peripheral.wrap(devName)
  21. end
  22. end
  23. end
  24.  
  25. local rednetSide = {"top","bottom","right","front"}
  26. local b = findAndWrap("openperipheral_bridge")
  27. local net = peripheral.wrap("right")
  28.  
  29.  
  30. -- type x y w h {c} {t} unit method {param} {var} minNumber maxNumber fadeout action
  31.  
  32. -- type text x y c
  33. -- type x y text unit method maxNumber c cMax var param
  34. -- type x y w h cBorder tBorder cBack tBack cOne tOne cTwo tTwo unit method maxNumber var param
  35. -- type x y w h minNumber maxNumber c t fadeout unit method var param
  36. -- type unit method operator limitNumber action
  37. -- type x y w h liquid cBorder tBorder cBack tBack unit method maxNumber var param
  38.  
  39.  
  40.  
  41.  
  42. -- tank with liquid
  43. -- addLiquid(number x, number y, number width, number height, string liquid)
  44. -- or?
  45. -- addFluid(number x, number y, number width, number height, string liquid) add a box textured like a liquid to the screen
  46. -- addIcon(number x, number y, string id, number meta) add an icom of an item to the screen (height width?)
  47.  
  48. for i=1, 199 do
  49. site[i] = {}
  50. screen[i] = {}
  51. end
  52.  
  53. function save()
  54. local file = fs.open("openPeripheralClient","w")
  55. file.writeLine("OPEN PERIPHERAL CLIENT DATABASE")
  56. file.writeLine(string.gsub(textutils.serialize(site),"\n%S-",""))
  57. file.writeLine(string.gsub(textutils.serialize(screen),"\n%S-",""))
  58. file.writeLine(updateInterval)
  59. file.writeLine(selected)
  60. file.close()
  61. end
  62.  
  63. function buildString(stringBuilder, site)
  64. stringBuilder = stringBuilder .. "{"
  65. local added = false
  66. for i, var in pairs(site) do -- VARIABLE
  67. added = true
  68. if type(var) == "string" then
  69. stringBuilder = stringBuilder .. "\"" .. var .. "\""
  70. elseif type(var) == "number" then
  71. stringBuilder = stringBuilder .. var
  72. elseif type(var) == "boolean" then
  73. stringBuilder = stringBuilder .. tostring(var)
  74. elseif type(var) == "table" then
  75. stringBuilder = buildString(stringBuilder, site[i])
  76. end
  77. stringBuilder = stringBuilder .. ","
  78. end
  79. if added then
  80. stringBuilder = stringBuilder:sub(1,stringBuilder:len()-1)
  81. end
  82. return stringBuilder .. "}"
  83. end
  84.  
  85. function load()
  86. if not fs.exists("openPeripheralClient") then return end
  87. local file = fs.open("openPeripheralClient","r")
  88. local firstLine = file.readLine()
  89. if firstLine == "OPEN PERIPHERAL CLIENT DATABASE" then -- NEWEST since 0.5
  90. site = textutils.unserialize(file.readLine())
  91. screen = textutils.unserialize(file.readLine())
  92. updateInterval = tonumber(file.readLine())
  93. selected = tonumber(file.readLine())
  94. file.close()
  95. elseif firstLine == "OPEN PERIPHERAL CLIENT DATA" then -- since 0.3
  96. site = textutils.unserialize(file.readLine())
  97. file.close()
  98. oldLoad03()
  99. else -- OLDEST since 0.1
  100. file.close()
  101. oldLoad01()
  102. end
  103. end
  104.  
  105. -- OLD LOAD
  106.  
  107. function oldLoad03()
  108. local newDB = {}
  109. for i=1,199 do
  110. newDB[i] = {}
  111. end
  112.  
  113. for siteID, s in pairs(site) do
  114. for objID, obj in pairs(s) do
  115. if obj[1] == "text" then
  116. newDB[siteID][objID] = {type=obj[1],text=obj[2],x=obj[3],y=obj[4],color=obj[5]}
  117. elseif obj[1] == "box" then
  118. newDB[siteID][objID] = {type=obj[1],x=obj[2],y=obj[3],w=obj[4],h=obj[5],inner_color=obj[6],inner_transparency=obj[7],border_color=obj[8],border_transparency=obj[9]}
  119. elseif obj[1] == "number" then
  120. newDB[siteID][objID] = {type=obj[1],x=obj[2],y=obj[3],text=obj[4],unit=obj[5],method=obj[6],maxNumber=obj[7],text_standardColor=obj[8],text_maxNumberColor=obj[9],arguments=obj[10]}
  121. elseif obj[1] == "bar" then
  122. newDB[siteID][objID] = {type=obj[1],x=obj[2],y=obj[3],w=obj[4],h=obj[5],color=obj[6],transparency=obj[7],color2=obj[8],transparency2=obj[9],color3=obj[10],transparency3=obj[11],color4=obj[12],transparency4=obj[13],unit=obj[14],method=obj[15],maxNumber=obj[16], arguments=obj[17]}
  123. elseif obj[1] == "graphPillar" or obj[1] == "graphPoint" then
  124. newDB[siteID][objID] = {type=obj[1],x=obj[2],y=obj[3],w=obj[4],h=obj[5],minNumber=obj[6],maxNumber=obj[7],color=obj[8],transparency=obj[9],fadeout=obj[10],unit=obj[11],method=obj[12],arguments=obj[14]}
  125. elseif obj[1] == "frame" then
  126. newDB[siteID][objID] = {type=obj[1],frame=obj[2],x=obj[3],y=obj[4]}
  127. elseif obj[1] == "ALARM" then
  128. if obj[7] == "TEXT" then
  129. newDB[siteID][objID] = {type=obj[1] ,unit=obj[2], method=obj[3], arguments=obj[4], operator=obj[5], number=obj[6], action_type=obj[7],action_x=obj[8],action_y=obj[9],action_text=obj[10], action_text_color=obj[11]}
  130. elseif obj[7] == "ACTIVATION" then
  131. newDB[siteID][objID] = {type=obj[1] ,unit=obj[2], method=obj[3], arguments=obj[4], operator=obj[5], number=obj[6], action_type=obj[7],action_unit=obj[8],action_method=obj[9],action_arguments=obj[10]}
  132. elseif obj[7] == "REDNET" then
  133. newDB[siteID][objID] = {type=obj[1] ,unit=obj[2], method=obj[3], arguments=obj[4], operator=obj[5], number=obj[6], action_type=obj[7],action_text=obj[9]}
  134. else
  135. newDB[siteID][objID] = {type=obj[1] ,unit=obj[2], method=obj[3], arguments=obj[4], operator=obj[5], number=obj[6], action_type=obj[7]}
  136. end
  137. elseif obj[1] == "CHAT" then
  138. if obj[3] == "TEXT" then
  139. newDB[siteID][objID] = {type=obj[1],text=obj[2],action_type=obj[3],action_x=obj[4],action_y=obj[5],action_text=obj[6], action_text_color=obj[7]}
  140. elseif obj[3] == "ACTIVATION" then
  141. newDB[siteID][objID] = {type=obj[1],text=obj[2],action_type=obj[3],action_unit=obj[4],action_method=obj[5],action_arguments=obj[6]}
  142. elseif obj[3] == "REDNET" then
  143. newDB[siteID][objID] = {type=obj[1],text=obj[2],action_type=obj[3],action_text=obj[5]}
  144. else
  145. newDB[siteID][objID] = {type=obj[1],text=obj[2],action_type=obj[3]}
  146. end
  147. elseif obj[1] == "REDNET" then
  148. if obj[3] == "TEXT" then
  149. newDB[siteID][objID] = {type=obj[1],text=obj[2],action_type=obj[3],action_x=obj[4],action_y=obj[5],action_text=obj[6], action_text_color=obj[7]}
  150. elseif obj[3] == "ACTIVATION" then
  151. newDB[siteID][objID] = {type=obj[1],text=obj[2],action_type=obj[3],action_unit=obj[4],action_method=obj[5],action_arguments=obj[6]}
  152. elseif obj[3] == "REDNET" then
  153. newDB[siteID][objID] = {type=obj[1],text=obj[2],action_type=obj[3],action_text=obj[5]}
  154. else
  155. newDB[siteID][objID] = {type=obj[1],text=obj[2],action_type=obj[3]}
  156. end
  157. end
  158. end
  159. end
  160. site = newDB
  161. save()
  162. load()
  163. end
  164.  
  165. function oldLoad01()
  166. if not fs.exists("openPeripheralClient") then return end
  167. local file = fs.open("openPeripheralClient","r")
  168. for i=1,198 do
  169. local amountObj = tonumber(file.readLine())
  170. for k=1,amountObj do
  171. local amountVars = tonumber(file.readLine())
  172. local typ = file.readLine()
  173. site[i][k] = {}
  174. site[i][k][1] = typ
  175. for m=2,amountVars do
  176. if typ == "text" then
  177. if m == 2 then
  178. site[i][k][m] = file.readLine()
  179. else
  180. site[i][k][m] = tonumber(file.readLine())
  181. end
  182. elseif typ == "box" then
  183. site[i][k][m] = tonumber(file.readLine())
  184. elseif typ == "number" then
  185. if m == 2 or m == 3 or m >= 7 then
  186. site[i][k][m] = tonumber(file.readLine())
  187. else
  188. site[i][k][m] = file.readLine()
  189. end
  190. elseif typ == "bar" then
  191. if (m >= 2 and m <=13) or m == 16 then
  192. site[i][k][m] = tonumber(file.readLine())
  193. else
  194. site[i][k][m] = file.readLine()
  195. end
  196. elseif typ == "graphPillar" or typ == "graphPoint" then
  197. if m >= 2 and m <= 9 then
  198. site[i][k][m] = tonumber(file.readLine())
  199. elseif m == 10 then
  200. if file.readLine() == "true" then
  201. site[i][k][m] = true
  202. else
  203. site[i][k][m] = false
  204. end
  205. elseif m == 11 or m == 12 then
  206. site[i][k][m] = file.readLine()
  207. else
  208. local amount = tonumber(file.readLine())
  209. site[i][k][m] = {}
  210. for a=1,amount do
  211. site[i][k][m][a] = tonumber(file.readLine())
  212. end
  213. end
  214. elseif typ == "frame" then
  215. site[i][k][m] = tonumber(file.readLine())
  216. end
  217. end
  218. end
  219. save()
  220. load()
  221. end
  222.  
  223. file.close()
  224. end
  225.  
  226. function clear(color)
  227. color = color or colors.black
  228. term.setBackgroundColor(color)
  229. term.clear()
  230. term.setCursorPos(1,1)
  231. end
  232.  
  233. function countArray(a)
  234. local amount = 0
  235. for k,v in pairs(a) do
  236. amount = amount + 1
  237. end
  238. return amount
  239. end
  240.  
  241. function write(text,x,y,c)
  242. c = c or colors.white
  243. term.setCursorPos(x,y)
  244. term.setTextColor(c)
  245. term.write(text)
  246. end
  247.  
  248. function centered(text,y,c)
  249. c = c or colors.white
  250. term.setCursorPos(w/2-math.ceil(#tostring(text)/2),y)
  251. term.setTextColor(c)
  252. term.write(tostring(text))
  253. end
  254.  
  255. function fill(text,y)
  256. centered(string.rep(tostring(text), w), y)
  257. end
  258.  
  259. function setColors(text,background)
  260. background = background or colors.lightGray
  261. term.setTextColor(text)
  262. term.setBackgroundColor(background)
  263. end
  264.  
  265. function drawArrows(y)
  266. write("<",14,y)
  267. write(">",36,y)
  268. end
  269.  
  270. -- CHECK ALARM AND ACTIVATIONS
  271.  
  272. function checkAlarm(chatCommand, rednetMessage) -- DONE 1
  273. chatCommand = chatCommand or ""
  274. rednetMessage = rednetMessage or ""
  275. local number = 0
  276. for objID, obj in pairs(site[199]) do
  277. if obj.type == "ALARM" then -- ALARM
  278. number = table.remove(screen[199][objID]["values"], 1)
  279. if type(number) == "number" then -- ERROR
  280. if obj.operator == "=" and number == obj.number then
  281. makeAction(obj, objID)
  282. elseif obj.operator == ">" and number > obj.number then
  283. makeAction(obj, objID)
  284. elseif obj.operator == "<"and number < obj.number then
  285. makeAction(obj, objID)
  286. end
  287. end
  288. elseif not (chatCommand == "") and obj.type == "CHAT" and obj.text == chatCommand then -- CHAT
  289. makeAction(obj, objID)
  290. elseif not (rednetMessage == "") and obj.type == "REDNET" and obj.text == rednetMessage then -- REDNET
  291. makeAction(obj, objID)
  292. end
  293. end
  294. end
  295.  
  296. function makeAction(obj, objID)
  297. if obj.action_type == "TEXT" then
  298. drawText(199, objID, 0, 0)
  299. elseif obj.action_type == "ACTIVATION" then
  300. if net.isPresentRemote(obj.action_unit) and obj.action_method ~= "NONE" and type(obj.action_arguments) == "table" then
  301. if countArray(obj.action_arguments) >= 1 then
  302. local noErr,res = pcall( net.callRemote, obj.action_unit, obj.action_method, unpack(obj.action_arguments))
  303. if not noErr then
  304. if errorText == nil then
  305. errorText = {"ERROR!!! ALARM'N'ACTION CALLING WITH ARGUMENTS! Object: " .. objID, "ORIGINAL ERROR MESSAGE: ".. res}
  306. end
  307. end
  308. else
  309. local noErr,res = pcall( net.callRemote, obj.action_unit, obj.action_method, unpack(obj.action_arguments))
  310. if not noErr then
  311. if errorText == nil then
  312. errorText = {"ERROR!!! ALARM'N'ACTION CALLING WITHOUT ARGUMENTS! Object: " .. objID, "ORIGINAL ERROR MESSAGE: ".. res}
  313. end
  314. end
  315. end
  316. end
  317. elseif obj.action_type == "REDNET" then
  318. rednet.broadcast(obj.action_text)
  319. end
  320. end
  321.  
  322.  
  323.  
  324.  
  325. -- ON SCREEN OBJECT DRAWING
  326.  
  327. -- type text x y c
  328. function drawText(siteID, objID, relX, relY)
  329. local obj = site[siteID][objID]
  330. if obj.type == "text" then
  331. local var = b.addText(obj.x+relY,obj.y+relY,obj.text,colorHex[obj.text_color])
  332. setZDimension(var)
  333. elseif obj.action_type == "TEXT" then
  334. local var = b.addText(obj.action_x+relX,obj.action_y+relY,obj.action_text,colorHex[obj.action_text_color])
  335. setZDimension(var)
  336. end
  337. end
  338.  
  339. -- type x y w h cOne tOne cTwo tTwo
  340. function drawBox(siteID, objID, relX, relY)
  341. local obj = site[siteID][objID]
  342. local cOne = colorHex[obj.inner_color]
  343. local cTwo = colorHex[obj.border_color]
  344. local var1 = b.addBox(obj.x+relX,obj.y+relY,obj.w,2,cTwo,obj.border_transparency)
  345. setZDimension(var1)
  346. local var2 = b.addBox(obj.x+relX,obj.y+2+relY,2,obj.h-4,cTwo,obj.border_transparency)
  347. setZDimension(var2)
  348. local var3 = b.addBox(obj.x+relX,obj.y+relY+obj.h-2,obj.w,2,cTwo,obj.border_transparency)
  349. setZDimension(var3)
  350. local var4 = b.addBox(obj.x+relX+obj.w-2,obj.y+relY+2,2,obj.h-4,cTwo,obj.border_transparency)
  351. setZDimension(var4)
  352. local var5 = b.addBox(obj.x+relX+2,obj.y+relY+2,obj.w-4,obj.h-4,cOne,obj.inner_transparency)
  353. setZDimension(var5)
  354. end
  355.  
  356. -- type x y text unit method maxNumber c cMax
  357. function drawNumber(siteID, objID, relX, relY)
  358. local obj = site[siteID][objID]
  359. local c = colorHex[obj.text_standardColor]
  360. local cMax = colorHex[obj.text_maxNumberColor]
  361. local number = table.remove(screen[siteID][objID]["values"], 1)
  362. if (type(number) == "table") then
  363. number = "ERROR table"
  364. end
  365. local lengthText = ((#tostring(obj.text)) + 2)*6
  366. local lengthNumber = (#(tostring(number)))*6
  367. local maxLength = (#(tostring(obj.maxNumber)))*6
  368. if type(number) == "string" or (type(number) == "number" and number == maxNumber) then
  369. local var1 = b.addText(obj.x+relX,obj.y+relY,obj.text .. ":",c)
  370. setZDimension(var1)
  371. local var2 = b.addText(obj.x+relX+lengthText,obj.y+relY,tostring(number),cMax)
  372. setZDimension(var2)
  373. local var3 = b.addText(obj.x+relX+lengthText+(#(tostring(number)))*6,obj.y+relY, " / " .. obj.maxNumber, c)
  374. setZDimension(var3)
  375. else
  376. local var1 = b.addText(obj.x+relX,obj.y+relY, obj.text .. ":", c )
  377. setZDimension(var1)
  378. local var2 = b.addText(obj.x+relX+lengthText+(maxLength-lengthNumber),obj.y+relY, tostring(number) .. " / " .. obj.maxNumber,c)
  379. setZDimension(var2)
  380. end
  381. end
  382.  
  383. -- type x y w h cBorder tBorder cBack tBack cOne tOne cTwo tTwo unit method maxNumber
  384. function drawBar(siteID, objID, relX, relY)
  385. local obj = site[siteID][objID]
  386. local cBorder = colorHex[obj.color3]
  387. local cBack = colorHex[obj.color4]
  388. local cOne = colorHex[obj.color]
  389. local cTwo = colorHex[obj.color2]
  390. local tBorder = obj.transparency3
  391. local tBack = obj.transparency4
  392. local tOne = obj.transparency
  393. local tTwo = obj.transparency2
  394. local var1 = b.addBox(obj.x+relX+2,obj.y+relY+2,obj.w-4,obj.h-4,cBack,tBack)
  395. setZDimension(var1)
  396. local var2 = b.addBox(obj.x+relX,obj.y+relY,obj.w,2,cBorder,tBorder)
  397. setZDimension(var2)
  398. local var3 = b.addBox(obj.x+relX,obj.y+relY+obj.h-2,obj.w,2,cBorder,tBorder)
  399. setZDimension(var3)
  400. local var4 = b.addBox(obj.x+relX,obj.y+relY+2,2,obj.h-4,cBorder,tBorder)
  401. setZDimension(var4)
  402. local var5 = b.addBox(obj.x+relX+obj.w-2,obj.y+relY+2,2,obj.h-4,cBorder,tBorder)
  403. setZDimension(var5)
  404. local number = table.remove(screen[siteID][objID]["values"], 1)
  405. if type(number) == "number" then
  406. local box = b.addGradientBox(obj.x+relX+2,obj.y+relY+2,math.ceil((number/obj.maxNumber)*(obj.w-4)),obj.h-4,cOne,tOne,cTwo,tTwo,2)
  407. z = z + 1
  408. setZDimension(box)
  409. end
  410. end
  411.  
  412. -- type x y w h minNumber maxNumber c t fadeout unit method var
  413. function drawGraph(siteID, objID, rX, rY)
  414. local obj = site[siteID][objID]
  415. local var = screen[siteID][objID]["values"]
  416. table.remove(screen[siteID][objID]["values"], math.ceil(obj.w+2/2))
  417. local t = obj.transparency
  418. local decrease = obj.transparency/20
  419. local c = colorHex[obj.color]
  420. for relX=2,obj.w,2 do
  421. if obj.fadeout and relX >= obj.w-20 and t > 0.05 then
  422. t = t - decrease
  423. end
  424. if obj.type == "graphPillar" then
  425. if type(var[relX/2]) == "number" then
  426. if var[relX/2] > obj.minNumber then
  427. local box = b.addBox(obj.x+rX+relX-2,obj.y+rY+(obj.h-1-(math.ceil((var[relX/2]/(obj.maxNumber))*obj.h))),2,(math.ceil((var[relX/2]/(obj.maxNumber))*obj.h)),c,t)
  428. setZDimension(box)
  429. else
  430. local box = b.addBox(obj.x+rX+relX-2,obj.y+rY+obj.h-2,2,1,c,t)
  431. setZDimension(box)
  432. end
  433. else
  434. local box = b.addBox(obj.x+rX+relX-2,obj.y+rY+obj.h-2,2,1,c,t)
  435. setZDimension(box)
  436. end
  437. else
  438. if type(var[relX/2]) == "number" then
  439. if var[relX/2] > obj.minNumber then
  440. local box = b.addBox(obj.x+rX+relX-2,obj.y+rY+(obj.h-1-((math.ceil((var[relX/2]/(obj.maxNumber))*obj.h)))),2,2,c,t)
  441. setZDimension(box)
  442. local box = b.addBox(obj.x+rX+relX-2,obj.y+rY+obj.h-1,2,1,c,t)
  443. setZDimension(box)
  444. else
  445. local box = b.addBox(obj.x+rX+relX-2,obj.y+rY+obj.h-1,2,1,c,t)
  446. setZDimension(box)
  447. end
  448. else
  449. local box = b.addBox(obj.x+rX+relX-2,obj.y+rY+obj.h-1,2,1,c,t)
  450. setZDimension(box)
  451. end
  452. end
  453. end
  454. end
  455.  
  456. function drawTank(siteID, objID, relX, relY)
  457. local obj = site[siteID][objID]
  458. local cBorder = colorHex[obj.cBorder]
  459. local cBack = colorHex[obj.cBack]
  460. local tBorder = obj.tBorder
  461. local tBack = obj.tBack
  462. local var1 = b.addBox(obj.x+relX+2,obj.y+relY+2,obj.w-4,obj.h-4,cBack,tBack)
  463. setZDimension(var1)
  464. local var2 = b.addBox(obj.x+relX,obj.y+relY,obj.w,2,cBorder,tBorder)
  465. setZDimension(var2)
  466. local var3 = b.addBox(obj.x+relX,obj.y+relY+obj.h-2,obj.w,2,cBorder,tBorder)
  467. setZDimension(var3)
  468. local var4 = b.addBox(obj.x+relX,obj.y+relY+2,2,obj.h-4,cBorder,tBorder)
  469. setZDimension(var4)
  470. local var5 = b.addBox(obj.x+relX+obj.w-2,obj.y+relY+2,2,obj.h-4,cBorder,tBorder)
  471. setZDimension(var5)
  472. local number = table.remove(screen[siteID][objID]["values"], 1)
  473. if type(number) == "number" then
  474. local relH = obj.h-math.ceil((number/obj.maxNumber)*obj.h)
  475. local box = b.addLiquid(obj.x+relX+2,obj.y+relH+relY+2,obj.w-4,obj.h-relH-4, obj.liquid)
  476. z = z + 1
  477. setZDimension(box)
  478. end
  479. end
  480.  
  481. function setZDimension(obj)
  482. local wtf = ( obj.setZ and obj.setZ(z) ) or ( obj.setZIndex and obj.setZIndex(z) )
  483. z = z + 1
  484. end
  485.  
  486.  
  487.  
  488. -- ON SCREEN DRAWING MAIN METHODS
  489.  
  490.  
  491.  
  492.  
  493. function drawSite(doUpdate)
  494. doUpdate = doUpdate or true
  495. if (doUpdate) then
  496. update()
  497. end
  498. if selected == 0 then return end
  499. z = 1
  500. b.clear()
  501. for i=1,4 do
  502. innerDraw(0,0,selected,i)
  503. end
  504. checkAlarm()
  505. b.sync()
  506. save()
  507. end
  508.  
  509.  
  510.  
  511. function update() -- DONE 1
  512. for siteID, selectedSite in pairs(site) do -- SITE
  513. for objID, obj in pairs(selectedSite) do -- OBJECT
  514. if siteID == selected or ( obj.type == "graphPillar" or obj.type == "graphPoint" or obj.type == "ALARM" or obj.type == "CHAT" or obj.type == "REDNET") then -- JUST NEEDED INFORMATION.
  515. if obj.unit ~= nil and obj.method ~= nil then
  516. callMethod(siteID, objID, obj, "unit", "method", "arguments","values")
  517. end
  518. if obj.action_type ~= "ACTIVATION" and obj.action_unit ~= nil and obj.action_method ~= nil then
  519. callMethod(siteID, objID, obj, "action_unit", "action_method", "action_arguments", "action_values")
  520. end
  521. end
  522. end
  523. end
  524. end
  525.  
  526. function callMethod(siteID, objID, obj, unit_pos, method_pos, arguments_pos, values_pos) -- DONE 1
  527. if screen[siteID][objID] == nil then
  528. screen[siteID][objID] = {}
  529. screen[siteID][objID]["values"] = {}
  530. screen[siteID][objID]["action_values"] = {}
  531. screen[siteID][objID]["objects"] = {}
  532. end
  533. if net.isPresentRemote(obj[unit_pos]) and obj[method_pos] ~= "NONE" then
  534. if type(obj[arguments_pos]) ~= "table" then
  535. table.insert(screen[siteID][objID]["values"], 1, "ERROR")
  536. table.insert(screen[siteID][objID]["action_values"], 1, "ERROR")
  537. return
  538. end
  539. if countArray(obj[arguments_pos]) == 0 then
  540. local noError, value = pcall( net.callRemote, obj[unit_pos], obj[method_pos] )
  541. if noError and (type(value) == "number" or type(value) == "string" or type(value) == "boolean") then
  542. table.insert(screen[siteID][objID][values_pos], 1, value)
  543. elseif errorText == nil then
  544. table.insert(screen[siteID][objID][values_pos], 1, "ERROR")
  545. if siteID <= 99 then siteID = "Site: " .. siteID
  546. elseif siteID <= 198 then siteID = "Frame: " .. siteID-99
  547. else siteID = "ALARM'N'ACTION"
  548. end
  549. if type(value) == "table" then
  550. value = "(Original Error code was a table. Unable to print.)"
  551. end
  552. errorText = {"ERROR! ".. siteID .. " Object: " .. objID .. " Unit: " .. obj[unit_pos] .. " Method: " .. obj[method_pos] .. " No arguments!", "Original Error Code: " .. tostring(value)}
  553. end
  554. else
  555. local noError, value = pcall( net.callRemote, obj[unit_pos], obj[method_pos], unpack(obj[arguments_pos]) )
  556. if noError and (type(value) == "number" or type(value) == "string" or type(value) == "boolean") then
  557. table.insert(screen[siteID][objID][values_pos], 1, value)
  558. elseif errorText == nil then
  559. table.insert(screen[siteID][objID][values_pos], 1, "ERROR")
  560. if siteID <= 99 then siteID = "Site: " .. siteID
  561. elseif siteID <= 198 then siteID = "Frame: " .. siteID-99
  562. else siteID = "ALARM'N'ACTION"
  563. end
  564. if type(value) == "table" then
  565. value = "(Original Error code was a table. Unable to print.)"
  566. end
  567. errorText = {"ERROR! ".. siteID .. " Object: " .. objID .. " Unit: " .. obj[unit_pos] .. " Method: " .. obj[method_pos] .. " Arguments: " .. countArray(obj[arguments_pos]), "Original Error Code: " .. tostring(value)}
  568. end
  569. end
  570. elseif countArray(screen[siteID][objID]["values"]) == 0 or countArray(screen[siteID][objID]["action_values"]) then
  571. table.insert(screen[siteID][objID]["values"], 1, "ERROR")
  572. table.insert(screen[siteID][objID]["action_values"], 1, "ERROR")
  573. end
  574. end
  575.  
  576.  
  577. function innerDraw(relX, relY, s, layer) -- DONE 1
  578. if layer == 4 then -- ERROR
  579. if type(errorText) == "table" then
  580. local length = #errorText[1]
  581. if #errorText[1] < #errorText[2] then
  582. length = #errorText[2]
  583. end
  584. local box1 = b.addBox(0,0,math.ceil(length*5.3),28,colorHex[1],1)
  585. setZDimension(box1)
  586. local box2 = b.addBox(0,28,1+math.ceil(length*5.3),2,colorHex[14],1)
  587. setZDimension(box2)
  588. local box3 = b.addBox(math.ceil(length*5.3),0,2,29,colorHex[14],1)
  589. setZDimension(box3)
  590. local var1 = b.addText(5,5,errorText[1],colorHex[14])
  591. setZDimension(var1)
  592. local var2 = b.addText(5,15, errorText[2],colorHex[14])
  593. setZDimension(var2)
  594. errorText = nil
  595. end
  596. end
  597.  
  598. for objID, obj in pairs(site[s]) do
  599. if obj.type == "frame" then
  600. innerDraw(obj.x, obj.y, obj.frame, layer)
  601. elseif layer == 1 then -- BOX
  602. if obj.type == "box" then
  603. drawBox(s, objID, relX, relY)
  604. end
  605. elseif layer == 2 then -- NUMBER, BAR, GRAPH
  606. if obj.type == "number" then
  607. drawNumber(s, objID, relX, relY)
  608. elseif obj.type == "bar" then
  609. drawBar(s, objID, relX, relY)
  610. elseif obj.type == "graphPillar" or obj.type == "graphPoint" then
  611. drawGraph(s, objID, relX, relY)
  612. elseif obj.type == "tank" then
  613. drawTank(s, objID, relX, relY)
  614. end
  615. elseif layer == 3 then -- TEXT
  616. if obj.type == "text" or obj.action_type == "TEXT" then
  617. drawText(s, objID, relX, relY)
  618. end
  619. end
  620. end
  621. end
  622.  
  623.  
  624.  
  625. -- MENU FUNCTIONS
  626.  
  627. function betterRead(x,y,numberOnly,pos,clickX) -- DONE 1
  628. local previousMode = mode
  629. local selectedSite = selected
  630. mode = "betterRead"
  631. term.setTextColor(colors.lightGray)
  632. term.setCursorBlink(true)
  633. local s
  634. if clickX < x then
  635. s = ""
  636. else
  637. s = tostring(site[selected][selectedObj][pos])
  638. end
  639.  
  640.  
  641. while true do
  642. term.setCursorPos(x,y)
  643. term.write( string.rep(' ', w - x + 1) )
  644. term.setCursorPos(x,y)
  645. if s:len()+x < w then
  646. term.write(s)
  647. else
  648. term.write(s:sub( s:len() - (w-x-2)))
  649. end
  650. local e = { os.pullEvent() }
  651. if e[1] == "mouse_click" then
  652. mode = "back"
  653. elseif e[1] == "char" then
  654. s = s .. e[2]
  655. elseif e[1] == "key" then
  656. if e[2] == keys.enter then
  657. mode = "back"
  658. elseif e[2] == keys.backspace then
  659. s = s:sub( 1, s:len() - 1 )
  660. end
  661. else
  662. checkEvent(e, false)
  663. end
  664. if mode == "back" then
  665. mode = previousMode
  666. break
  667. elseif not (mode == "betterRead") then
  668. break
  669. end
  670. end
  671.  
  672. term.setTextColor(colors.white)
  673. if numberOnly then
  674. s = tonumber(s)
  675. if s then
  676. site[selectedSite][selectedObj][pos] = s
  677. end
  678. else
  679. site[selectedSite][selectedObj][pos] = s
  680. end
  681. term.setCursorBlink(false)
  682. end
  683.  
  684.  
  685. function drawColor(color,y) -- DONE 1
  686. drawArrows(y)
  687. term.setBackgroundColor(colorName[color])
  688. centered(" ",y)
  689. term.setBackgroundColor(colors.black)
  690. end
  691.  
  692. function drawTransparent(transparency,y) -- DONE 1
  693. drawArrows(y)
  694. centered(transparency, y)
  695. end
  696.  
  697.  
  698. function changeColor(x, color) -- DONE 1
  699. if x < 25 then
  700. site[selected][selectedObj][color] = site[selected][selectedObj][color] - 1
  701. else
  702. site[selected][selectedObj][color] = site[selected][selectedObj][color] + 1
  703. end
  704. if site[selected][selectedObj][color] <= 0 then
  705. site[selected][selectedObj][color] = 15
  706. elseif site[selected][selectedObj][color] >= 16 then
  707. site[selected][selectedObj][color] = 1
  708. end
  709. end
  710.  
  711. function changeTransparence(x, transparency) -- DONE 1
  712. if x < 25 then
  713. site[selected][selectedObj][transparency] = site[selected][selectedObj][transparency] - 0.1
  714. else
  715. site[selected][selectedObj][transparency] = site[selected][selectedObj][transparency] + 0.1
  716. end
  717. if site[selected][selectedObj][transparency] < 0 then
  718. site[selected][selectedObj][transparency] = 1
  719. elseif site[selected][selectedObj][transparency] > 1 then
  720. site[selected][selectedObj][transparency] = 0
  721. end
  722. end
  723.  
  724.  
  725.  
  726. -- QUATERNARY MENUS
  727.  
  728. function menuArguments(unit_pos, method_pos, arguments_pos, amount, args, advancedMethodsSupport) -- DONE 1
  729. local previousMode = mode
  730. mode = "arguments"
  731.  
  732. local param = site[selected][selectedObj][arguments_pos]
  733. if advancedMethodsSupport then
  734. for i=1, amount do
  735. if args[i]["type"] == "NUMBER" and param[i] == nil then
  736. param[i] = i
  737. elseif param[i] == nil then
  738. param[i] = "Argument" .. i
  739. end
  740. end
  741. end
  742.  
  743.  
  744. while true do
  745. -- DRAW
  746. amount = countArray(param)
  747. clear()
  748. centered("ENTER ARGUMENTS FOR METHOD " .. site[selected][selectedObj][method_pos], 1)
  749. fill("-", 2)
  750. centered("APPLY", 15)
  751. for i=1, amount do
  752. write("ARG ".. i ..": " .. param[i],11,3+i)
  753. end
  754. if not advancedMethodsSupport and amount <= 10 then
  755. centered("ADD NEW MANUAL ARGUMENT", 16)
  756. end
  757. if not advancedMethodsSupport and amount > 0 then
  758. centered("DELETE LAST ARGUMENT", 17)
  759. end
  760.  
  761. -- EVENT
  762. local event = { os.pullEvent() }
  763. if checkEvent(event) then
  764. x,y = event[3], event[4]
  765. if y >= 4 and y <= amount+3 then
  766. site[selected][selectedObj][arguments_pos] = param[y-3]
  767. if advancedMethodsSupport then
  768. if args[y-3]["type"] == "NUMBER" then
  769. betterRead(18,y,true,arguments_pos,x)
  770. else
  771. betterRead(18,y,false,arguments_pos,x)
  772. end
  773. else -- not advancedMethodsSupport
  774. betterRead(18,y,false,arguments_pos,x)
  775. local tempVar = tonumber(site[selected][selectedObj][arguments_pos])
  776. if tempVar then
  777. site[selected][selectedObj][arguments_pos] = tempVar
  778. end
  779. end
  780. param[y-3] = site[selected][selectedObj][arguments_pos]
  781. elseif not advancedMethodsSupport and amount <= 10 and y == 16 then
  782. param[amount+1] = "Manual Argument" .. amount+1
  783. elseif not advancedMethodsSupport and amount > 0 and y == 17 then
  784. param[amount] = nil
  785. elseif y == 15 then
  786. mode = "back"
  787. end
  788. end
  789.  
  790. -- BACK TO MENU
  791. if mode == "back" then
  792. mode = previousMode
  793. break
  794. elseif not (mode == "arguments") then
  795. break
  796. end
  797. end
  798. site[selected][selectedObj][arguments_pos] = param
  799. save()
  800. end
  801.  
  802.  
  803.  
  804.  
  805.  
  806.  
  807. -- TERTIARY MENUS
  808.  
  809. function menuUnit(unit_pos, method_pos, arguments_pos) -- DONE 1
  810. clear()
  811. local list = net.getNamesRemote()
  812. if countArray(list) == 0 then
  813. centered("NOTHING ATTACHED TO THE NETWORK!",9)
  814. while true do
  815. local event = {os.pullEvent()}
  816. if event[1] == "timer" and event[2] == delay then
  817. drawSite()
  818. delay = os.startTimer(updateInterval)
  819. else
  820. return "NONE"
  821. end
  822. end
  823. end
  824.  
  825. local selectedUnit = 1
  826. for k,v in pairs(list) do
  827. selectedUnit = selectedUnit + 1
  828. if advancedMethodsSupport and v["name"] == site[selected][selectedObj][unit_pos] then
  829. break
  830. elseif not advancedMethodsSupport and v == site[selected][selectedObj][unit_pos] then
  831. break
  832. end
  833. end
  834. selectedUnit = selectedUnit - 1
  835.  
  836. selectedUnit = 1
  837. local previousMode = mode
  838. mode = "unit"
  839. while true do
  840. -- DRAW
  841. clear()
  842. centered("SELECT A UNIT",1)
  843. fill("-",2)
  844. centered("SELECT",14)
  845. fill(" ",9)
  846. drawArrows(9)
  847. centered(list[selectedUnit],9)
  848.  
  849. -- EVENT
  850. local event = { os.pullEvent() }
  851. if checkEvent(event) then
  852. x,y = event[3], event[4]
  853. if y >= 8 and y <= 10 then
  854. if x <= 25 then
  855. selectedUnit = selectedUnit - 1
  856. else
  857. selectedUnit = selectedUnit + 1
  858. end
  859. if selectedUnit == 0 then
  860. selectedUnit = countArray(list)
  861. elseif selectedUnit > countArray(list) then
  862. selectedUnit = 1
  863. end
  864. elseif y == 14 then
  865. mode = "back"
  866. end
  867. end
  868.  
  869. -- BACK TO MENU
  870. if mode == "back" then
  871. mode = previousMode
  872. break
  873. elseif not (mode == "unit") then
  874. break
  875. end
  876. end
  877. site[selected][selectedObj][unit_pos] = list[selectedUnit]
  878. site[selected][selectedObj][method_pos] = "NONE"
  879. site[selected][selectedObj][arguments_pos] = {}
  880. end
  881.  
  882.  
  883.  
  884.  
  885. function menuMethod(method_pos, unit_pos, arguments_pos, allReturnTypes) -- DONE 1
  886. local unit = site[selected][selectedObj][unit_pos]
  887. allReturnTypes = allReturnTypes or false
  888. clear()
  889. if not net.isPresentRemote(unit) then
  890. return "NONE"
  891. end
  892.  
  893. -- methods available?
  894. local basicMethods = net.getMethodsRemote(unit)
  895. if basicMethods ~= nil and countArray(basicMethods) == 0 then
  896. centered("NO METHOD FOUND!",9)
  897. while true do
  898. local event = {os.pullEvent()}
  899. if event[1] == "timer" and event[2] == delay then
  900. drawSite()
  901. delay = os.startTimer(updateInterval)
  902. else
  903. break
  904. end
  905. end
  906. return "NONE"
  907. end
  908.  
  909. -- advanced or normal support? (fixed by blunty666)
  910. local advancedMethodsSupport = false
  911. local unitType = "NONE"
  912. local advancedMethodsList = {}
  913. for k,v in pairs(basicMethods) do
  914. if v == "getAdvancedMethodsData" then
  915. advancedMethodsSupport = true
  916. unitType = net.getTypeRemote(unit)
  917. advancedMethodsList = net.callRemote(unit, "getAdvancedMethodsData")
  918. break
  919. end
  920. end
  921.  
  922. --[[ get advanced methods if possible
  923. local list = {}
  924. if advancedMethodsSupport then
  925. for k,v in pairs(advancedMethodsList) do
  926. if allReturnTypes or ( v["returnType"] ~= nil and v["returnType"] ) or ( v["returnTypes"][1] == "number" ) then
  927. table.insert(list, 1, v)
  928. end
  929. end
  930. else
  931. list = net.getMethodsRemote(unit)
  932. end]]
  933.  
  934.  
  935. -- get advanced methods if possible (fixed by blunty666)
  936. local list = {}
  937. if advancedMethodsSupport then
  938. for k,v in pairs(advancedMethodsList) do
  939. if allReturnTypes or ( v["returnType"] ~= nil and v["returnType"] ) or ( v["returnTypes"][1] == "number" ) then
  940. v.name = k
  941. table.insert(list, 1, v)
  942. end
  943. end
  944. else
  945. list = net.getMethodsRemote(unit)
  946. end
  947.  
  948.  
  949.  
  950.  
  951. -- still methods with number as return value available?
  952. if advancedMethodsSupport and (list == nil or countArray(list) == 0) then
  953. centered("NO METHOD FOUND!",9)
  954. while true do
  955. local event = {os.pullEvent()}
  956. if event[1] == "timer" and event[2] == delay then
  957. drawSite()
  958. delay = os.startTimer(updateInterval)
  959. else
  960. break
  961. end
  962. end
  963. return "NONE"
  964. end
  965.  
  966.  
  967.  
  968.  
  969. -- selection of the method
  970. local method = 1
  971. for k,v in pairs(list) do
  972. method = method + 1
  973. if advancedMethodsSupport and v["name"] == site[selected][selectedObj][method_pos] then
  974. break
  975. elseif not advancedMethodsSupport and v == site[selected][selectedObj][method_pos] then
  976. break
  977. end
  978. end
  979. method = method - 1
  980.  
  981. local previousMode = mode
  982. local previousSelected = selected
  983. mode = "method"
  984. while true do
  985. -- DRAW
  986. clear()
  987. centered("SELECT A METHOD FROM " .. unit ,1)
  988. fill("-",2)
  989. centered("SELECT",16)
  990. local methodName = "UNKNOWN"
  991. local methodDescription = "UNKNOWN! No Advanced Methods Support available!"
  992. local methodReturnType = "UNKNOWN"
  993. local methodArgumentamount = 1337
  994. local methodArgs = {}
  995. if advancedMethodsSupport then
  996. local counter = 1
  997. for k, v in pairs(list) do
  998. if counter == method then
  999. methodName = v["name"]
  1000. methodDescription = v["description"]
  1001. methodReturnType = v["returnType"] or v["returnTypes"][1] or "nil"
  1002. methodArgumentamount = countArray(v["args"]) or 0
  1003. methodArgs = v["args"] or {}
  1004. break
  1005. end
  1006. counter = counter + 1
  1007. end
  1008. else
  1009. methodDescription = "UNKNOWN! No Advanced Methods Support available!"
  1010. methodReturnType = "UNKNOWN"
  1011. methodArgumentamount = 0
  1012. methodName = list[method]
  1013. end
  1014.  
  1015.  
  1016. fill(" ",6)
  1017. drawArrows(6)
  1018. centered(methodName, 6)
  1019. term.setCursorPos(1,8)
  1020. print(" Description: " .. methodDescription)
  1021. print(" Returns: " .. methodReturnType)
  1022. print(" Arguments: " .. methodArgumentamount)
  1023. if advancedMethodsSupport and methodArgumentamount >= 1 then
  1024. centered("SET OR CHANGE ARGUMENTS", 15)
  1025. elseif not advancedMethodsSupport then
  1026. centered("SET OR CHANGE ARGUMENTS (OWN RISK)", 15)
  1027. end
  1028. -- EVENT
  1029. local event = { os.pullEvent() }
  1030. if checkEvent(event) then
  1031. site[selected][selectedObj][method_pos] = methodName
  1032. x,y = event[3], event[4]
  1033. if y >= 5 and y <= 8 then
  1034. site[selected][selectedObj][arguments_pos] = {}
  1035. screen[selected][selectedObj][arguments_pos] = {}
  1036. if x <= 25 then
  1037. method = method - 1
  1038. else
  1039. method = method + 1
  1040. end
  1041. if method == 0 then
  1042. method = countArray(list)
  1043. elseif method > countArray(list) then
  1044. method = 1
  1045. end
  1046. elseif advancedMethodsSupport and methodArgumentamount >= 1 and y == 15 then
  1047. menuArguments(unit_pos, method_pos, arguments_pos, methodArgumentamount, methodArgs, true)
  1048. elseif not advancedMethodsSupport and y == 15 then
  1049. menuArguments(unit_pos, method_pos, arguments_pos, countArray(site[selected][selectedObj][arguments_pos]), methodArgs, false)
  1050. elseif y == 16 then
  1051. mode = "back"
  1052. end
  1053. end
  1054.  
  1055. -- BACK TO MENU
  1056. if mode == "back" then
  1057. mode = previousMode
  1058. break
  1059. elseif not (mode == "method") then
  1060. break
  1061. end
  1062. end
  1063. end
  1064.  
  1065.  
  1066. -- SECONDARY MENUS
  1067.  
  1068. function menuSiteOrFrame(setMode) -- DONE 1
  1069. mode = setMode
  1070. local selectedFrame = 100
  1071. if mode == "site" then
  1072. selected = 1
  1073. else
  1074. selected = 100
  1075. end
  1076. selectedObj = 1
  1077. while true do
  1078. -- DRAW
  1079. clear()
  1080. drawArrows(1)
  1081. if mode == "site" then
  1082. centered("SITE " .. selected ,1)
  1083. elseif mode == "frame" then
  1084. centered("FRAME " .. selected-99 ,1)
  1085. end
  1086. fill("-",2)
  1087. local obj = site[selected][selectedObj]
  1088. if type(obj) == "table" then
  1089. centered(selectedObj.. " - " .. obj.type , 3)
  1090. else
  1091. centered(selectedObj , 3)
  1092. end
  1093. drawArrows(3)
  1094. fill("-",4)
  1095. write("BACK",48,1)
  1096. if type(obj) == "table" then -- object exists
  1097. write("DELETE",1,1)
  1098. if obj.type == "text" then -- TEXT
  1099. write("TEXT: " .. obj.text,10,7)
  1100. write("X: " .. obj.x,10,9)
  1101. write("Y: " .. obj.y,10,11)
  1102. drawColor(obj.text_color,13)
  1103. elseif obj.type == "box" then -- BOX
  1104. write("X: " .. obj.x,10,5)
  1105. write("Y: " .. obj.y,10,6)
  1106. write("WIDTH: " .. obj.w,10,7)
  1107. write("HEIGHT: " .. obj.h,10,8)
  1108. drawColor(obj.border_color,9)
  1109. drawTransparent(obj.border_transparency,10)
  1110. drawColor(obj.inner_color,11)
  1111. drawTransparent(obj.inner_transparency,12)
  1112. elseif obj.type == "number" then -- NUMBER
  1113. write("X: "..obj.x,10,5)
  1114. write("Y: "..obj.y,10,6)
  1115. write("TEXT: "..obj.text,10,7)
  1116. write("UNIT: "..obj.unit,10,8)
  1117. write("METHOD: "..obj.method,10,9)
  1118. write("MAX: "..obj.maxNumber,10,10)
  1119. drawColor(obj.text_standardColor,11)
  1120. drawColor(obj.text_maxNumberColor,12)
  1121. elseif obj.type == "bar" then -- BAR
  1122. write("X: "..obj.x,10,5)
  1123. write("Y: "..obj.y,10,6)
  1124. write("WIDTH: "..obj.w,10,7)
  1125. write("HEIGHT: "..obj.h,10,8)
  1126. write("UNIT: "..obj.unit,10,9)
  1127. write("METHOD: "..obj.method,29,9)
  1128. write("MAX: "..obj.maxNumber,10,10)
  1129. drawColor(obj.color,11)
  1130. drawTransparent(obj.transparency,12)
  1131. drawColor(obj.color2,13)
  1132. drawTransparent(obj.transparency2,14)
  1133. drawColor(obj.color3,15)
  1134. drawTransparent(obj.transparency3,16)
  1135. drawColor(obj.color4,17)
  1136. drawTransparent(obj.transparency4,18)
  1137. write("ADD AUTO TEXT", 10, 19)
  1138. elseif obj.type == "graphPillar" or obj.type == "graphPoint" then
  1139. -- GRAPHS
  1140. write("X: "..obj.x,10,5)
  1141. write("Y: "..obj.y,10,6)
  1142. write("WIDTH: "..obj.w,10,7)
  1143. write("HEIGHT: "..obj.h,10,8)
  1144. write("UNIT: "..obj.unit,10,9)
  1145. write("METHOD: "..obj.method,10,10)
  1146. write("MIN: "..obj.minNumber,10,11)
  1147. write("MAX: "..obj.maxNumber,10,12)
  1148. drawColor(obj.color,13)
  1149. drawTransparent(obj.transparency,14)
  1150. write("FADEOUT: "..tostring(obj.fadeout),10,15)
  1151. write("TYPE: " ..obj.type,10,16)
  1152. write("ADD AUTO BOX", 10, 17)
  1153. elseif obj.type == "frame" then -- FRAME
  1154. centered(obj.frame-99,5)
  1155. drawArrows(5)
  1156. fill("-",6)
  1157. write("X: "..obj.x,10,8)
  1158. write("Y: "..obj.y,10,10)
  1159. elseif obj.type == "tank" then -- TANK
  1160. write("X: "..obj.x,10,5)
  1161. write("Y: "..obj.y,10,6)
  1162. write("WIDTH: "..obj.w,10,7)
  1163. write("HEIGHT: "..obj.h,10,8)
  1164. write("UNIT: "..obj.unit,10,9)
  1165. write("METHOD: "..obj.method,10,10)
  1166. write("MAX: "..obj.maxNumber,10,11)
  1167. write("LIQUID: "..obj.liquid,10,12)
  1168. drawColor(obj.cBorder,13)
  1169. drawTransparent(obj.tBorder,14)
  1170. drawColor(obj.cBack,15)
  1171. drawTransparent(obj.tBack,16)
  1172. end
  1173. else --create new object
  1174. write("TEXT",20,6)
  1175. write("BOX",20,7)
  1176. write("NUMBER",20,8)
  1177. write("BAR",20,9)
  1178. write("GRAPH (PILLAR)",20,10)
  1179. write("GRAPH (POINT)",20,11)
  1180. write("TANK",20,12)
  1181. if mode == "site" then
  1182. write("FRAME",20,13)
  1183. end
  1184. end
  1185.  
  1186. -- EVENT
  1187. local event = { os.pullEvent() }
  1188. if checkEvent(event) then
  1189. x, y = event[3], event[4]
  1190. if y == 1 and x >= w-4 then
  1191. mode = "mainmenu"
  1192. elseif type(site[selected][selectedObj]) == "table" and y == 1 and x <=6 then
  1193. site[selected][selectedObj] = nil
  1194. if selectedObj >= 2 then
  1195. selectedObj = selectedObj - 1
  1196. end
  1197. elseif y == 1 then
  1198. selectedObj = 1
  1199. if x < 25 then
  1200. selected = selected - 1
  1201. else
  1202. selected = selected + 1
  1203. end
  1204. if mode == "site" then
  1205. if selected <= 0 then
  1206. selected = 99
  1207. elseif selected >= 100 then
  1208. selected = 1
  1209. end
  1210. elseif mode == "frame" then
  1211. if selected <= 99 then
  1212. selected = 198
  1213. elseif selected >= 199 then
  1214. selected = 100
  1215. end
  1216. end
  1217. elseif y >= 2 and y <= 4 then
  1218. if x < 25 then
  1219. selectedObj = selectedObj - 1
  1220. else
  1221. selectedObj = selectedObj + 1
  1222. end
  1223. if selectedObj == 0 then
  1224. selectedObj = 1
  1225. end
  1226. elseif type(site[selected][selectedObj]) == "table" then
  1227. if site[selected][selectedObj].type == "text" then
  1228. if y == 7 then
  1229. betterRead(16,y,false,"text",x)
  1230. elseif y == 9 then
  1231. betterRead(16,y,true,"x",x)
  1232. elseif y == 11 then
  1233. betterRead(16,y,true,"y",x)
  1234. elseif y == 13 then
  1235. changeColor(x,"text_color")
  1236. end
  1237. elseif site[selected][selectedObj].type == "box" then
  1238. if y == 5 then
  1239. betterRead(18,y,true,"x",x)
  1240. elseif y == 6 then
  1241. betterRead(18,y,true,"y",x)
  1242. elseif y == 7 then
  1243. betterRead(18,y,true,"w",x)
  1244. elseif y == 8 then
  1245. betterRead(18,y,true,"h",x)
  1246. elseif y == 9 then
  1247. changeColor(x,"border_color")
  1248. elseif y == 10 then
  1249. changeTransparence(x,"border_transparency")
  1250. elseif y == 11 then
  1251. changeColor(x,"inner_color")
  1252. elseif y == 12 then
  1253. changeTransparence(x,"inner_transparency")
  1254. end
  1255. elseif site[selected][selectedObj].type == "number" then
  1256. if y == 5 then
  1257. betterRead(18,y,true,"x",x)
  1258. elseif y == 6 then
  1259. betterRead(18,y,true,"y",x)
  1260. elseif y == 7 then
  1261. betterRead(18,y,false,"text",x)
  1262. elseif y == 8 then
  1263. menuUnit("unit","method","arguments")
  1264. elseif y == 9 then
  1265. if x < 18 then
  1266. menuMethod("method","unit","arguments",true)
  1267. else
  1268. menuMethod("method","unit","arguments",false)
  1269. end
  1270. elseif y == 10 then
  1271. betterRead(18,y,true,"maxNumber",x)
  1272. elseif y == 11 then
  1273. changeColor(x,"text_standardColor")
  1274. elseif y == 12 then
  1275. changeColor(x,"text_maxNumberColor")
  1276. end
  1277. elseif site[selected][selectedObj].type == "bar" then
  1278. if y == 5 then
  1279. betterRead(18,y,true,"x",x)
  1280. elseif y == 6 then
  1281. betterRead(18,y,true,"y",x)
  1282. elseif y == 7 then
  1283. betterRead(18,y,true,"w",x)
  1284. elseif y == 8 then
  1285. betterRead(18,y,true,"h",x)
  1286. elseif y == 9 then
  1287. if x < 28 then
  1288. menuUnit("unit","method","arguments")
  1289. else
  1290. if x < 18 then
  1291. menuMethod("method","unit","arguments",true)
  1292. else
  1293. menuMethod("method","unit","arguments",false)
  1294. end
  1295. end
  1296. elseif y == 10 then
  1297. betterRead(18,y,true,"maxNumber",x)
  1298. elseif y == 11 then
  1299. changeColor(x,"color")
  1300. elseif y == 12 then
  1301. changeTransparence(x,"transparency")
  1302. elseif y == 13 then
  1303. changeColor(x,"color2")
  1304. elseif y == 14 then
  1305. changeTransparence(x,"transparency2")
  1306. elseif y == 15 then
  1307. changeColor(x,"color3")
  1308. elseif y == 16 then
  1309. changeTransparence(x,"transparency3")
  1310. elseif y == 17 then
  1311. changeColor(x,"color4")
  1312. elseif y == 18 then
  1313. changeTransparence(x,"transparency4")
  1314. elseif y == 19 then
  1315. local bar = site[selected][selectedObj]
  1316. local textProperties = {type="text",text="YOUR TEXT",x=bar.x-59,y=bar.y+4,text_color=bar.color}
  1317. table.insert(site[selected], selectedObj+1, textProperties )
  1318. selectedObj = selectedObj+1
  1319.  
  1320. betterRead(25,y,false,"text",50)
  1321. site[selected][selectedObj].x = bar.x - 10 - math.floor(5.5 * #site[selected][selectedObj].text)
  1322. end
  1323. elseif site[selected][selectedObj].type == "graphPillar" or site[selected][selectedObj].type == "graphPoint" then
  1324. if y == 5 then
  1325. betterRead(19,y,true,"x",x)
  1326. elseif y == 6 then
  1327. betterRead(19,y,true,"y",x)
  1328. elseif y == 7 then
  1329. betterRead(19,y,true,"w",x)
  1330. elseif y == 8 then
  1331. betterRead(19,y,true,"h",x)
  1332. elseif y == 9 then
  1333. menuUnit("unit","method","arguments")
  1334. elseif y == 10 then
  1335. if x < 18 then
  1336. menuMethod("method","unit","arguments",true)
  1337. else
  1338. menuMethod("method","unit","arguments",false)
  1339. end
  1340. elseif y == 11 then
  1341. betterRead(19,y,true,"minNumber",x)
  1342. elseif y == 12 then
  1343. betterRead(19,y,true,"maxNumber",x)
  1344. elseif y == 13 then
  1345. changeColor(x,"color")
  1346. elseif y == 14 then
  1347. changeTransparence(x,"transparency")
  1348. elseif y == 15 then
  1349. site[selected][selectedObj].fadeout = not site[selected][selectedObj].fadeout
  1350. elseif y == 16 then
  1351. if site[selected][selectedObj].type == "graphPoint" then
  1352. site[selected][selectedObj].type = "graphPillar"
  1353. elseif site[selected][selectedObj].type == "graphPillar" then
  1354. site[selected][selectedObj].type = "graphPoint"
  1355. end
  1356. elseif y == 17 then
  1357. local g = site[selected][selectedObj]
  1358. local boxProperties = {type="box", x=g.x-4, y=g.y-6, w=g.w+8, h=g.h+10, inner_color=1, inner_transparency=0.4, border_color=g.color, border_transparency=0.9}
  1359. table.insert(site[selected], selectedObj+1, boxProperties )
  1360. selectedObj = selectedObj+1
  1361. end
  1362. elseif site[selected][selectedObj].type == "tank" then
  1363. if y == 5 then
  1364. betterRead(18,y,true,"x",x)
  1365. elseif y == 6 then
  1366. betterRead(18,y,true,"y",x)
  1367. elseif y == 7 then
  1368. betterRead(18,y,true,"w",x)
  1369. elseif y == 8 then
  1370. betterRead(18,y,true,"h",x)
  1371. elseif y == 9 then
  1372. menuUnit("unit","method","arguments")
  1373. elseif y == 10 then
  1374. if x < 18 then
  1375. menuMethod("method","unit","arguments",true)
  1376. else
  1377. menuMethod("method","unit","arguments",false)
  1378. end
  1379. elseif y == 11 then
  1380. betterRead(18,y,true,"maxNumber",x)
  1381. elseif y == 12 then
  1382. betterRead(18,y,false,"liquid",x)
  1383. elseif y == 13 then
  1384. changeColor(x,"cBorder")
  1385. elseif y == 14 then
  1386. changeTransparence(x,"tBorder")
  1387. elseif y == 15 then
  1388. changeColor(x,"cBack")
  1389. elseif y == 16 then
  1390. changeTransparence(x,"tBack")
  1391. end
  1392. elseif site[selected][selectedObj].type == "frame" then
  1393. if y == 5 then
  1394. if x < 25 then
  1395. site[selected][selectedObj].frame = site[selected][selectedObj].frame - 1
  1396. else
  1397. site[selected][selectedObj].frame = site[selected][selectedObj].frame + 1
  1398. end
  1399. if site[selected][selectedObj].frame == 99 then
  1400. site[selected][selectedObj].frame = 198
  1401. elseif site[selected][selectedObj].frame == 199 then
  1402. site[selected][selectedObj].frame = 100
  1403. end
  1404. elseif y == 8 then
  1405. betterRead(13,y,true,"x",x)
  1406. elseif y == 10 then
  1407. betterRead(13,y,true,"y",x)
  1408. end
  1409. end
  1410. else -- CREATE
  1411. if y == 6 then
  1412. site[selected][selectedObj] = {type="text",text="UNOBTANIUM",x=1,y=1,text_color=1}
  1413. elseif y == 7 then
  1414. site[selected][selectedObj] = {type="box",x=1,y=1,w=10,h=10,inner_color=1,inner_transparency=0.4,border_color=15,border_transparency=1}
  1415. elseif y == 8 then
  1416. site[selected][selectedObj] = {type="number",x=1,y=1,text="UNOBTANIUM",unit="NONE",method="NONE",maxNumber=1337,text_standardColor=1,text_maxNumberColor=14,arguments={}}
  1417. elseif y == 9 then
  1418. site[selected][selectedObj] = {type="bar",x=1,y=1,w=40,h=15,color=1,transparency=1,color2=2,transparency2=1,color3=3,transparency3=1,color4=4,transparency4=1,unit="NONE",method="NONE",maxNumber=1337, arguments={}}
  1419. elseif y == 10 then
  1420. site[selected][selectedObj] = {type="graphPillar",x=1,y=1,w=100,h=40,minNumber=0,maxNumber=1337,color=1,transparency=1,fadeout=false,unit="NONE",method="NONE",arguments={}}
  1421. elseif y == 11 then
  1422. site[selected][selectedObj] = {type="graphPoint",x=1,y=1,w=100,h=40,minNumber=0,maxNumber=1337,color=1,transparency=1,fadeout=false,unit="NONE",method="NONE",arguments={}}
  1423. elseif y == 12 then
  1424. site[selected][selectedObj] = {type="tank",x=1,y=1,w=15,h=40,cBorder=1,tBorder=1,cBack=2,tBack=1,unit="NONE",method="NONE",maxNumber=1337, liquid="water", arguments={}}
  1425. elseif y == 13 and mode == "site" then
  1426. site[selected][selectedObj] = {type="frame",frame=100,x=0,y=0}
  1427. end
  1428. end
  1429. end
  1430.  
  1431. -- BACK TO MENU
  1432. if not (mode == "site" or mode == "frame") then
  1433. break
  1434. end
  1435. end
  1436. end
  1437.  
  1438.  
  1439.  
  1440. function menuAlarm() -- DONE 1
  1441. mode = "alarm"
  1442. local previousSelected = selected
  1443. selected = 199
  1444. selectedObj = 1
  1445. while true do
  1446. local obj = site[199][selectedObj]
  1447. -- DRAW
  1448. clear()
  1449. b.clear()
  1450. centered("ALARM'N'ACTION", 1)
  1451. fill("-",2)
  1452. if type(site[199][selectedObj]) == "table" then
  1453. centered(selectedObj .. " - " .. obj.type, 3)
  1454. else
  1455. centered(selectedObj, 3)
  1456. end
  1457. drawArrows(3)
  1458. fill("-",4)
  1459. write("BACK", 48, 1)
  1460. local relY = 0
  1461. if type(obj) == "table" and obj.type == "ALARM" then
  1462. write("DELETE", 1, 1)
  1463. write("UNIT: "..obj.unit, 10, 6)
  1464. write("METHOD: "..obj.method, 10, 7)
  1465. write("NUMBER: "..obj.operator .. " " .. obj.number, 10, 8)
  1466. write("ACTION: "..obj.action_type, 10, 9)
  1467. relY = 2
  1468. elseif type(obj) == "table" and obj.type == "CHAT" then
  1469. write("DELETE", 1, 1)
  1470. write("COMMAND: $$"..obj.text, 10, 6)
  1471. write("ACTION: "..obj.action_type, 10, 7)
  1472. elseif type(obj) == "table" and obj.type == "REDNET" then
  1473. write("DELETE", 1, 1)
  1474. write("MESSAGE: "..obj.text, 10, 6)
  1475. write("ACTION: "..obj.action_type, 10, 7)
  1476. else
  1477. write("ALARM", 10, 9)
  1478. write("CHAT", 10, 10)
  1479. write("REDNET", 10 , 11)
  1480. end
  1481.  
  1482. if type(obj) == "table" then
  1483. if obj.action_type == "TEXT" then
  1484. write("| X: "..obj.action_x, 10, 8+relY)
  1485. write("| Y: "..obj.action_y, 10, 9+relY)
  1486. write("| TEXT: "..obj.action_text, 10, 10+relY)
  1487. drawColor(obj.action_text_color, 11+relY)
  1488. elseif obj.action_type == "ACTIVATION" then
  1489. write("| UNIT: "..obj.action_unit, 10, 8+relY)
  1490. write("| METHOD: "..obj.action_method, 10, 9+relY)
  1491. elseif obj.action_type == "REDNET" then
  1492. write("| MESSAGE: "..obj.action_text, 10, 8+relY)
  1493. end
  1494. end
  1495.  
  1496. -- EVENT
  1497. local event = { os.pullEvent() }
  1498. if checkEvent(event) then
  1499. x, y = event[3], event[4]
  1500. if y == 1 and x <= 6 and type(site[199][selectedObj]) == "table" then
  1501. site[199][selectedObj] = nil
  1502. if selectedObj >= 2 then
  1503. selectedObj = selectedObj - 1
  1504. end
  1505. elseif y == 1 and x >= 48 then
  1506. save()
  1507. selected = previousSelected
  1508. selectedObj = 1
  1509. mode = "mainmenu"
  1510. elseif y == 3 or y == 4 then
  1511. if x > 25 then
  1512. selectedObj = selectedObj + 1
  1513. elseif selectedObj > 1 then
  1514. selectedObj = selectedObj - 1
  1515. end
  1516. elseif type(site[199][selectedObj]) == "table" and site[199][selectedObj].type == "ALARM" then -- ALARM
  1517. if y == 6 then
  1518. menuUnit("unit","method","arguments")
  1519. elseif y == 7 then
  1520. if x < 20 then
  1521. menuMethod("method", "unit","arguments",true)
  1522. else
  1523. menuMethod("method", "unit","arguments",false)
  1524. end
  1525. elseif y == 8 and x >=19 and x <= 21 then
  1526. if site[199][selectedObj].operator == "=" then
  1527. site[199][selectedObj].operator = ">"
  1528. elseif site[199][selectedObj].operator == ">" then
  1529. site[199][selectedObj].operator = "<"
  1530. elseif site[199][selectedObj].operator == "<" then
  1531. site[199][selectedObj].operator = "="
  1532. end
  1533. elseif y == 8 then
  1534. betterRead(23,y,true,"number",x)
  1535. elseif y == 9 then
  1536. setAction()
  1537. elseif site[199][selectedObj].action_type == "TEXT" then -- ALARM: TEXT
  1538. if y == 10 then
  1539. betterRead(21,y,true,"action_x",x)
  1540. elseif y == 11 then
  1541. betterRead(21,y,true,"action_y",x)
  1542. elseif y == 12 then
  1543. betterRead(21,y,false,"action_text",x)
  1544. elseif y == 13 then
  1545. changeColor(x,"action_text_color")
  1546. end
  1547. elseif site[199][selectedObj].action_type == "ACTIVATION" then -- ALARM: ACTIVATION
  1548. if y == 10 then
  1549. menuUnit("action_unit","action_method","action_arguments")
  1550. elseif y == 11 then
  1551. if x < 20 then
  1552. menuMethod("action_method", "action_unit", "action_arguments", true)
  1553. else
  1554. menuMethod("action_method", "action_unit", "action_arguments",false)
  1555. end
  1556. end
  1557. elseif site[199][selectedObj].action_type == "REDNET" then -- ALARM: REDNET
  1558. if y == 10 then
  1559. betterRead(21,y,false,"action_text",x)
  1560. end
  1561. end
  1562.  
  1563. elseif type(site[199][selectedObj]) == "table" and ( site[199][selectedObj].type == "CHAT" or site[199][selectedObj].type == "REDNET") then -- CHAT AND REDNET
  1564. if y == 6 then
  1565. betterRead(21,y,false,"text",x)
  1566. elseif y == 7 then
  1567. setAction()
  1568. elseif site[199][selectedObj].action_type == "TEXT" then -- ALARM: TEXT
  1569. if y == 8 then
  1570. betterRead(21,y,true,"action_x",x)
  1571. elseif y == 9 then
  1572. betterRead(21,y,true,"action_y",x)
  1573. elseif y == 10 then
  1574. betterRead(21,y,false,"action_text",x)
  1575. elseif y == 11 then
  1576. changeColor(x,"action_text_color")
  1577. end
  1578. elseif site[199][selectedObj].action_type == "ACTIVATION" then -- ALARM: ACTIVATION
  1579. if y == 8 then
  1580. menuUnit("action_unit","action_method","action_arguments")
  1581. elseif y == 9 then
  1582. if x < 20 then
  1583. menuMethod("action_method", "action_unit","action_arguments",true)
  1584. else
  1585. menuMethod("action_method", "action_unit", "action_arguments",false)
  1586. end
  1587. end
  1588. elseif site[199][selectedObj].action_type == "REDNET" then -- ALARM: REDNET
  1589. if y == 8 then
  1590. betterRead(21,y,false,"action_text",x)
  1591. end
  1592. end
  1593.  
  1594. else -- CREATE NEW
  1595. site[199][selectedObj] = {}
  1596. if y == 9 then
  1597. site[199][selectedObj] = {type="ALARM" ,unit="NONE", method="NONE", arguments={}, operator="=", number=42, action_type="NONE"}
  1598. elseif y == 10 then
  1599. site[199][selectedObj] = {type="CHAT",text="NONE",action_type="NONE"}
  1600. elseif y == 11 then
  1601. site[199][selectedObj] = {type="REDNET",text="NONE",action_type="NONE"}
  1602. end
  1603. end
  1604. end
  1605.  
  1606. -- BACK TO MENU
  1607. if not (mode == "alarm") then
  1608. selected = previousSelected
  1609. break
  1610. end
  1611. end
  1612. end
  1613.  
  1614. function setAction() -- DONE 1
  1615. if site[199][selectedObj].action_type == "NONE" then
  1616. site[199][selectedObj].action_type = "TEXT"
  1617. site[199][selectedObj].action_x = 1
  1618. site[199][selectedObj].action_y = 1
  1619. site[199][selectedObj].action_text = "UNOBTANIUM"
  1620. site[199][selectedObj].action_text_color = 1
  1621. elseif site[199][selectedObj].action_type == "TEXT" then
  1622. site[199][selectedObj].action_type = "ACTIVATION"
  1623. site[199][selectedObj].action_unit = "NONE"
  1624. site[199][selectedObj].action_method = "NONE"
  1625. site[199][selectedObj].action_arguments = {}
  1626. site[199][selectedObj].action_text_color = nil
  1627. site[199][selectedObj].action_text = nil
  1628. site[199][selectedObj].action_x = nil
  1629. site[199][selectedObj].action_y = nil
  1630. elseif site[199][selectedObj].action_type == "ACTIVATION" then
  1631. site[199][selectedObj].action_type = "REDNET"
  1632. site[199][selectedObj].action_text = "UNOBTANIUM"
  1633. site[199][selectedObj].action_unit = nil
  1634. site[199][selectedObj].action_method = nil
  1635. site[199][selectedObj].action_arguments = nil
  1636. elseif site[199][selectedObj].action_type == "REDNET" then
  1637. site[199][selectedObj].action_type = "NONE"
  1638. site[199][selectedObj].action_text = nil
  1639. end
  1640. end
  1641.  
  1642.  
  1643.  
  1644. -- PRIMARY MENUS
  1645.  
  1646. function mainMenu() -- DONE 1
  1647. mode = "mainmenu"
  1648. while true do
  1649. for _, side in pairs(rednetSide) do
  1650. if peripheral.getType(side) == "modem" then
  1651. rednet.open(side)
  1652. end
  1653. end
  1654.  
  1655. -- DRAW
  1656. clear()
  1657. centered("CLIENT FOR OPENPERIPERAL'S GLASSES", 1)
  1658. fill("-", 2)
  1659. write("by UNOBTANIUM", w-13, h)
  1660. write("Site",20,6)
  1661. write("Frame",20,8)
  1662. write("Alarm'n'Action",20,10)
  1663. write("Quit",20,13)
  1664. write("< " .. updateInterval .. " >",2, h)
  1665.  
  1666. -- EVENT
  1667. local event = { os.pullEvent() }
  1668. if checkEvent(event) then
  1669. x, y = event[3], event[4]
  1670. if y == 6 then
  1671. menuSiteOrFrame("site")
  1672. elseif y == 8 then
  1673. menuSiteOrFrame("frame")
  1674. elseif y == 10 then
  1675. menuAlarm()
  1676. elseif y == 13 then
  1677. save()
  1678. b.clear()
  1679. mode = "quit"
  1680. elseif y == h then
  1681. if x <= 3 then
  1682. updateInterval = updateInterval / 2
  1683. elseif x >=10 and x <= 12 and updateInterval < 16 then
  1684. updateInterval = updateInterval * 2
  1685. end
  1686. if updateInterval < 0.5 then
  1687. updateInterval = 0.5
  1688. end
  1689. end
  1690. end
  1691.  
  1692. if mode == "quit" then
  1693. break
  1694. end
  1695. end
  1696. end
  1697.  
  1698.  
  1699.  
  1700. -- EVENT HANDLING
  1701.  
  1702. function checkEvent(event, justUpdate, charAndKeyEvent)
  1703. charAndKeyEvent = charAndKeyEvent or false
  1704. justUpdate = justUpdate or false
  1705. if event[1] == "timer" and event[2] == delay then
  1706. if justUpdate then
  1707. update()
  1708. else
  1709. drawSite()
  1710. end
  1711. delay = os.startTimer(updateInterval)
  1712.  
  1713. elseif event[1] == "mouse_click" or (charAndKeyEvent and ( event[1] == "char" or event[1] == "key" )) then
  1714. return true
  1715.  
  1716. elseif event[1] == "glasses_chat_command" then
  1717. mode = "mainmenu"
  1718. checkAlarm(event[5])
  1719. if event[5] == "clear" or event[5] == "" then
  1720. b.clear()
  1721. b.sync()
  1722. selected = 0
  1723. elseif event[5] == "sync" then
  1724. b.clear()
  1725. local var = b.addText(10, 10, "Sync!", colorHex[14])
  1726. setZDimension(var)
  1727. b.sync()
  1728. sleep(updateInterval)
  1729. delay = os.startTimer(0.2)
  1730.  
  1731. else
  1732. for i=1,99 do
  1733. if event[5] == "site"..i then
  1734. selected = i
  1735. drawSite(false)
  1736. break
  1737. end
  1738. end
  1739. end
  1740.  
  1741. elseif event[1] == "rednet_message" then
  1742. checkAlarm("", tostring(event[3]))
  1743. end
  1744.  
  1745. return false
  1746. end
  1747.  
  1748.  
  1749. -- START
  1750.  
  1751. load()
  1752. mainMenu()
  1753. clear()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement