· 4 years ago · Jul 25, 2021, 02:58 AM
1-- Base Monitoring System
2-- Version 0.2
3-----------------------------------------------------------------------------------------------------------------
4-- Tested on Computercraft version 1.58
5-- Minecraft version 1.6.4
6-----------------------------------------------------------------------------------------------------------------
7-- NOTE: THIS IS A WORK IN PROGRESS
8-----------------------------------------------------------------------------------------------------------------
9--
10-- This code was written by Impshial and is free software:
11-- You can redistribute it and/or modify
12-- it under the terms of the GNU General Public License as published by
13-- the Free Software Foundation, either version 3 of the License, or
14-- (at your option) any later version.
15
16-- This program is distributed in the hope that it will be useful,
17-- but WITHOUT ANY WARRANTY; without even the implied warranty of
18-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19-- GNU General Public License for more details.
20--
21-- See https://www.gnu.org/licenses/ for details
22--
23-- Pastebin for this program: https://pastebin.com/B6kvjRxZ
24--
25-- Pastebin for the ImpShial API: https://pastebin.com/pwBMKNCb
26--
27-- Instructions:
28-- 1. Place an Advanced Computer
29-- 2. Attach wired Modem to computer
30-- 3. Set up a monitor (if there is no monitor present, the program will let you know)
31-- 4. Attach wired Modem to monitor
32-- 5. Connect computer and monitor via Network Cables
33-- 6. Right-click each modem to connect devices to network
34-- 7. Run the following command in Computer Terminal: "pastebin get B6kvjRxZ startup"
35-- 8. Run "startup" (API will be downloaded and installed in this step)
36-- 9. Attach machines via Modems and newtwork cable. Machines will automatically show up on monitor when connected
37-- 10. Right-click on machine name to get details
38--
39-----------------------------------------------------------------------------------------------------------------
40-- Version notes:
41-- Added button-click capability for machines
42-- Works with all Thermal expansion machines
43-- Works with most Minefactory Reloaded machines
44-- GPL License verbiage added
45-----------------------------------------------------------------------------------------------------------------
46-- Bugs:
47-- Right-click intermittantly works
48-- Delay between right-click and machine being selected
49-----------------------------------------------------------------------------------------------------------------
50--
51-- Begin Program
52--
53-----------------------------------------------------------------------------------------------------------------
54
55-- Variables
56local version = "0.3" -- Program Version
57local scale -- the text scale for the monitor
58local monX -- Monitor Width
59local monY -- Monitor Height
60local line -- Monitor line variable
61local sizeXY -- Text scale
62local mainLoop -- Main loop variable. set to < 1 to stop loop
63local tableMachines = {} -- Main machine table
64local render -- Should we render the machine list?
65local renderReason -- Why is our monitor too small?
66local clicked -- Has the user clicked a machine?
67local clickedLine -- which line was clicked
68local headerFooterColor -- Color for the header/footer bar
69local headerFooterTextColor -- Color for header/footer text
70local selectedBackColor -- Colors for selected item background
71local selectedTextColor -- Colors for selected item text
72local detailsKeyColumn -- Column to start at for details Key
73local altColor1 -- Alternating line color 1
74local altColor2 -- Alternating line color 2
75local altColorSwitch -- Which color are we on. 0 or 1
76local detailsValueColumn -- Column to start at for details Value
77local debugMode -- For testing
78
79-----------------------------------------------------------------------------------------------------------------
80-- Local Functions
81-----------------------------------------------------------------------------------------------------------------
82
83-- Get number from machine/entity name
84function getMachineEntityNumber(machineName)
85 lastChars = string.sub(machineName, -2)
86
87 if string.match(lastChars, "_") then
88 return string.sub(lastChars, -1)
89 else
90 return string.sub(lastChars, -2)
91 end
92
93
94end
95-----------------------------------------------------------------------------------------------------------------
96-- Startup code
97-----------------------------------------------------------------------------------------------------------------
98
99-- Write startup message to Terminal
100term.clear()
101
102-- Check to see if the API file exists
103if fs.exists("ImpAPI") == false then
104 term.setCursorPos(1,1)
105 term.setTextColor(colors.red)
106 term.write("Missing API File! Attempting to download...")
107 term.setTextColor(colors.white)
108 shell.run("pastebin get pwBMKNCb ImpAPI") -- Go out and download it
109 sInput = nil
110 term.setCursorPos(1,5)
111 term.setTextColor(colors.green)
112 term.write("API Loaded.")
113 term.setCursorPos(1,7)
114 term.setTextColor(colors.white)
115 term.write("Press enter to continue...")
116 while true do
117 sInput = read()
118 if sInput ~= nil or sInput ~= "" then
119 break
120
121 end
122 end
123end
124
125os.loadAPI("ImpAPI")
126
127term.clear()
128ImpAPI.draw_line_term(1,1,55,colors.green)
129term.setCursorPos(1,1)
130term.write("Base Monitoring System")
131ImpAPI.draw_line_term(1,2,55,colors.black)
132term.setCursorPos(1,3)
133term.write("Version"..version)
134term.setCursorPos(1,5)
135term.write("Finding Monitor...")
136
137-- Find our monitor and define it
138mon=ImpAPI.monitorSearch()
139
140-- Check to see if a monitor exists
141if mon then -- Found it
142 ImpAPI.CTWrite(1,6,"Monitor Found!",colors.green)
143 ImpAPI.CTWrite(1,8,"System Running",colors.orange)
144
145else -- No monitor Present
146 ImpAPI.CTWrite(1,6,"Monitor Not Found!",colors.red)
147 ImpAPI.CTWrite(1,8,"Please Attach a Monitor",colors.red)
148 term.setCursorPos(1,9)
149 return
150end
151
152-- Set the initial text scale
153scale = 0.5
154
155-- Set the begining line for our text
156line = 1
157
158-- Set the initial text scale
159sizeXY = 1
160
161-- Set the main Loop variable
162mainLoop = 1
163
164-- Set our monitor to the initial text scale
165mon.setTextScale(sizeXY)
166
167-- Write out our machine list
168render = true
169
170-- Nothing has been clicked
171clicked = false
172
173-- Set our header/footer color
174headerFooterColor = colors.blue
175
176-- Set our header/footer text color
177headerFooterTextColor = colors.white
178
179-- Set background color for selected machine
180selectedBackColor = colors.white
181
182-- Set text color for selected machine
183selectedTextColor = colors.black
184
185-- Set the details Key column
186detailsKeyColumn = 43
187
188-- Set the details value column value
189detailsValueColumn = 55
190
191altColor1 = colors.black
192
193altColor2 = colors.gray
194
195altColorSwitch = 0
196
197-- Debug mode?
198debugMode = false
199-----------------------------------------------------------------------------------------------------------------
200-- Main Loop
201-----------------------------------------------------------------------------------------------------------------
202
203while mainLoop > 0 do
204
205 -- Get our monitor size
206 monX, monY = mon.getSize()
207
208 -- Change textScale when monitor size changes
209 if monX < 62 and scale == 1 then
210
211 scale = 0.5
212 elseif monX > 142 and scale < 1 then
213
214 scale = 0.5
215 elseif monX < 143 and scale < 1 then
216
217 scale = 0.5
218 end
219
220 mon.setTextScale(scale)
221
222 -- If monitor is too small, let the user know
223
224 if monX < 79 and scale == 0.5 then
225 render = false
226 renderReason = "Reason: Width"
227 elseif monY < 24 and scale == .05 then
228 render = false
229 renderReason = "Reason: Height"
230 elseif monY < 19 and scale == 1 then
231 render = false
232 renderReason = "Reason: Height"
233 else
234 render = true
235 end
236
237 -- Get all peripherals on the network
238 machines=peripheral.getNames()
239
240 --Create/Clear out main machine table
241 tableMachines = {}
242
243
244 if render == true then
245
246-----------------------------------------------------------------------------------------------------------------
247-- Loop through machines
248-----------------------------------------------------------------------------------------------------------------
249 for i = 1, #machines do
250 machNbr = getMachineEntityNumber(machines[i])
251
252 if string.match(machines[i], "thermalexpansion_machine_furnace") then
253
254 -- Check to see if furnace is active
255 machine=peripheral.wrap(machines[i])
256 isActive=machine.getStackInSlot(1)
257 itemInSlot1 = ""
258 itemQtyInSlot1 = ""
259 itemInSlot2 = ""
260 ItemQtyInSlot2 = ""
261
262 activeText = ""
263
264 if isActive then
265 activeText = "Active"
266 else
267 activeText = "InActive"
268 end
269
270 processing=machine.getStackInSlot(1)
271 processed1=machine.getStackInSlot(2)
272
273 if processing then
274
275 for k,v in pairs(processing) do
276 if k == "name" then
277 itemInSlot1 = v
278 elseif k == ("qty") then
279 itemQtyInSlot1 = tostring(v)
280 end
281 end
282 else
283 itemInSlot1 = "Nothing"
284 itemQtyInSlot1 = "0"
285 end
286
287 if processed1 then
288 for k,v in pairs(processed1) do
289 if k == "name" then
290 itemInSlot2 = v
291 elseif k == ("qty") then
292 itemQtyInSlot2 = tostring(v)
293 end
294 end
295 else
296 itemInSlot2 = "Nothing"
297 itemQtyInSlot2 = "0"
298 end
299
300 table.insert(tableMachines, { ["Machine"]="Redstone Furnace",
301 ["Number"]=machNbr,
302 ["HasEnergy"]=true,
303 ["Energy"]=machine.getEnergy(),
304 ["IsActive"]=activeText,
305 ["PerName"]=machines[i],
306 ["MaxEnergy"]=machine.getMaxEnergy(),
307 ["ItemInSlot1"]=itemInSlot1,
308 ["ItemQtyInSlot1"]=itemQtyInSlot1,
309 ["slot1Name"]="Processing: ",
310 ["ItemInSlot2"]=itemInSlot2,
311 ["ItemQtyInSlot2"]=itemQtyInSlot2,
312 ["slot2Name"]="Output: ",
313 ["InventorySlots"]=2})
314
315
316 elseif string.match(machines[i], "thermalexpansion_machine_pulverizer") then
317
318 -- Check to see if pulverizer is active
319 -- Check to see if furnace is active
320 machine=peripheral.wrap(machines[i])
321 isActive=machine.getStackInSlot(1)
322 itemInSlot1 = ""
323 itemQtyInSlot1 = ""
324 itemInSlot2 = ""
325 ItemQtyInSlot2 = ""
326 itemInSlot3 = ""
327 ItemQtyInSlot3 = ""
328
329 activeText = ""
330
331 if isActive then
332 activeText = "Active"
333 else
334 activeText = "InActive"
335 end
336
337 processing=machine.getStackInSlot(1)
338 processed1=machine.getStackInSlot(2)
339 processed2=machine.getStackInSlot(4)
340
341 if processing then
342
343 for k,v in pairs(processing) do
344 if k == "name" then
345 itemInSlot1 = v
346 elseif k == ("qty") then
347 itemQtyInSlot1 = tostring(v)
348 end
349 end
350 else
351 itemInSlot1 = "Nothing"
352 itemQtyInSlot1 = "0"
353 end
354
355 if processed1 then
356 for k,v in pairs(processed1) do
357 if k == "name" then
358 itemInSlot2 = v
359 elseif k == ("qty") then
360 itemQtyInSlot2 = tostring(v)
361 end
362 end
363 else
364 itemInSlot2 = "Nothing"
365 itemQtyInSlot2 = "0"
366 end
367
368 if processed2 then
369 for k,v in pairs(processed2) do
370 if k == "name" then
371 itemInSlot3 = v
372 elseif k == ("qty") then
373 itemQtyInSlot3 = tostring(v)
374 end
375 end
376 else
377 itemInSlot3 = "Nothing"
378 itemQtyInSlot3 = "0"
379 end
380
381 table.insert(tableMachines, { ["Machine"]="Pulverizer",
382 ["Number"]=machNbr,
383 ["HasEnergy"]=true,
384 ["Energy"]=machine.getEnergy(),
385 ["IsActive"]=activeText,
386 ["PerName"]=machines[i],
387 ["MaxEnergy"]=machine.getMaxEnergy(),
388 ["ItemInSlot1"]=itemInSlot1,
389 ["ItemQtyInSlot1"]=itemQtyInSlot1,
390 ["slot1Name"]="Processing: ",
391 ["ItemInSlot2"]=itemInSlot2,
392 ["ItemQtyInSlot2"]=itemQtyInSlot2,
393 ["slot2Name"]="Output: ",
394 ["ItemInSlot3"]=itemInSlot3,
395 ["ItemQtyInSlot3"]=itemQtyInSlot3,
396 ["slot3Name"]="Bonus: ",
397 ["InventorySlots"]=3})
398
399
400 elseif string.match(machines[i], "thermalexpansion_machine_smelter") then
401
402 -- Check to see if induction smelter is active
403 machine=peripheral.wrap(machines[i])
404 isActive=machine.getStackInSlot(1)
405
406 if isActive then
407 tableMachines["Induction Smelter "..machNbr] = "Active"
408 else
409 tableMachines["Induction Smelter "..machNbr] = "Inactive"
410 end
411 elseif string.match(machines[i], "thermalexpansion_machine_crucible") then
412
413 -- Check to see if pulverizer is active
414 machine=peripheral.wrap(machines[i])
415 isActive=machine.getStackInSlot(1)
416 if isActive then
417 tableMachines["Magma Crucible "..machNbr] = "Active"
418 else
419 tableMachines["Magma Crucible "..machNbr] = "Inactive"
420 end
421
422
423 elseif string.match(machines[i], "thermalexpansion_machine_transposer") then
424
425 -- Check to see if transposer is active
426 machine=peripheral.wrap(machines[i])
427 isActive=machine.getStackInSlot(1)
428 if isActive then
429 activeText = "Active"
430 else
431 activeText = "InActive"
432 end
433
434 processing=machine.getStackInSlot(1)
435
436
437
438 if processing then
439
440 for k,v in pairs(processing) do
441 if k == "name" then
442 itemInSlot1 = v
443 elseif k == ("qty") then
444 itemQtyInSlot1 = tostring(v)
445 end
446 end
447 else
448 itemInSlot1 = "Nothing"
449 itemQtyInSlot1 = "0"
450 end
451
452
453 table.insert(tableMachines, { ["Machine"]="Fluid Transposer",
454 ["Number"]=machNbr,
455 ["HasEnergy"]=true,
456 ["Energy"]=machine.getEnergy(),
457 ["IsActive"]=activeText,
458 ["ItemInSlot1"]=itemInSlot1,
459 ["ItemQtyInSlot1"]=itemQtyInSlot1
460 })
461 end
462 end
463
464-----------------------------------------------------------------------------------------------------------------
465-- Write static text to main monitor
466-----------------------------------------------------------------------------------------------------------------
467 mon.clear()
468
469 -- Header
470 ImpAPI.draw_line(1, line, monX, headerFooterColor, mon)
471 ImpAPI.CWrite(1, line, mon, "Networked Machines", headerFooterTextColor)
472 ImpAPI.CWrite(29, line, mon, "Status", headerFooterTextColor)
473 ImpAPI.CWrite(40, line, mon, "Energy", headerFooterTextColor)
474 ImpAPI.CWrite(58, line, mon, "Processing", headerFooterTextColor)
475 ImpAPI.CWrite(94, line, mon, "Output", headerFooterTextColor)
476 ImpAPI.CWrite(118, line, mon, "Bonus Output", headerFooterTextColor)
477
478 -- Center details location based on monitor width
479 -- startLeft = 41 + ((monX - 41) / 2 - 3)
480 -- ImpAPI.CWrite(startLeft, line, mon, "Details", headerFooterTextColor)
481
482 line = line + 2
483
484 -- Details line
485 -- for l = 2,(monY -1) do
486 -- if altColorSwitch == 0 then
487 -- ImpAPI.draw_line(1, l, monX, altColor1, mon)
488 -- altColorSwitch = 1
489 -- else
490 -- ImpAPI.draw_line(1, l, monX, altColor2, mon)
491 -- altColorSwitch = 0
492 -- end
493 -- end
494
495
496 -- Footer
497 ImpAPI.draw_line(1, monY, monX, headerFooterColor, mon)
498 ImpAPI.CWrite(1,monY,mon,"Impshial Base Monitor: v"..version, headerFooterTextColor)
499 ImpAPI.draw_line(1, (monY+1), monX, colors.black, mon)
500
501-----------------------------------------------------------------------------------------------------------------
502-- Begin machine loop
503-----------------------------------------------------------------------------------------------------------------
504
505 altColorSwitch = 1
506 ImpAPI.draw_line(1, 2, monX, altColor1, mon)
507
508 for i = 1,#tableMachines do
509 machName = tableMachines[i].Machine
510 machNumber = tableMachines[i].Number
511 machHasEnergy = tableMachines[i].HasEnergy
512 invSlots = tableMachines[i].InventorySlots
513
514 machColor = colors.white
515
516
517 --ImpAPI.draw_line(1,line, 39, colors.black, mon)
518
519 mon.setCursorPos(2,line)
520
521 if altColorSwitch == 0 then
522 ImpAPI.draw_line(1, line, monX, altColor1, mon)
523 altColorSwitch = 1
524 else
525 ImpAPI.draw_line(1, line, monX, altColor2, mon)
526 altColorSwitch = 0
527 end
528
529
530 if clicked == true and clickedLine == line then
531 machColor = selectedTextColor
532 else
533 if string.match(machName,"Furnace") then
534 machColor = colors.cyan
535 elseif string.match(machName,"Pulverizer") then
536 machColor = colors.orange
537 elseif string.match(machName,"Induction") then
538 machColor = colors.lime
539 elseif string.match(machName,"Crucible") then
540 machColor = colors.lightBlue
541 elseif string.match(machName,"Transposer") then
542 machColor = colors.lightGray
543 end
544 end
545
546
547 ImpAPI.CWrite(2,line,mon, machName.." "..machNumber, machColor)
548 -- Status
549 if tableMachines[i].IsActive == "InActive" then
550 ImpAPI.CWrite(29,line,mon, tableMachines[i].IsActive, colors.red)
551
552 else
553 ImpAPI.CWrite(29,line,mon, tableMachines[i].IsActive, colors.green)
554
555 end
556
557
558 --ImpAPI.CWrite(40, line, mon, tableMachines[i].Energy.."/"..tableMachines[i].MaxEnergy, colors.white)
559
560
561 if machName == "Redstone Furnace" then
562
563 if tableMachines[i].ItemInSlot1 == "Nothing" then
564 ImpAPI.CWrite(58, line, mon, tableMachines[i].ItemInSlot1, colors.red)
565 else
566 ImpAPI.CWrite(58, line, mon, tableMachines[i].ItemInSlot1, colors.orange)
567 end
568
569 if tableMachines[i].ItemInSlot2 == "Nothing" then
570 ImpAPI.CWrite(94, line, mon, tableMachines[i].ItemInSlot2, colors.red)
571 else
572 ImpAPI.CWrite(94, line, mon, tableMachines[i].ItemInSlot2, colors.orange)
573 end
574
575 end
576
577 if machName == "Pulverizer" then
578
579 if tableMachines[i].ItemInSlot1 == "Nothing" then
580 ImpAPI.CWrite(58, line, mon, tableMachines[i].ItemInSlot1, colors.red)
581 else
582 ImpAPI.CWrite(58, line, mon, tableMachines[i].ItemInSlot1, colors.orange)
583 end
584
585 if tableMachines[i].ItemInSlot2 == "Nothing" then
586 ImpAPI.CWrite(94, line, mon, tableMachines[i].ItemInSlot2, colors.red)
587 else
588 ImpAPI.CWrite(94, line, mon, tableMachines[i].ItemInSlot2, colors.orange)
589 end
590
591 if tableMachines[i].ItemInSlot3 == "Nothing" then
592 ImpAPI.CWrite(118, line, mon, tableMachines[i].ItemInSlot3, colors.red)
593 else
594 ImpAPI.CWrite(118, line, mon, tableMachines[i].ItemInSlot3, colors.orange)
595 end
596 end
597
598 if machName == "Fluid Transposer" then
599
600 if tableMachines[i].ItemInSlot1 == "Nothing" then
601 ImpAPI.CWrite(58, line, mon, tableMachines[i].ItemInSlot1, colors.red)
602 else
603 ImpAPI.CWrite(58, line, mon, tableMachines[i].ItemInSlot1, colors.orange)
604 end
605
606
607
608 end
609
610-----------------------------------------------------------------------------------------------------------------
611-- Details
612-----------------------------------------------------------------------------------------------------------------
613
614 detailsLine = 3
615
616 --if clicked == true and clickedLine == line then
617 -- Machine Name
618 --ImpAPI.draw_line(detailsKeyColumn, detailsLine, (monX - detailsKeyColumn), colors.black, mon)
619 --ImpAPI.CWrite(detailsKeyColumn, detailsLine, mon, "Machine: ", colors.orange)
620 --ImpAPI.CWrite(detailsValueColumn, detailsLine, mon, machName.." "..machNumber, colors.white)
621 --detailsLine = detailsLine + 1
622
623 -- Energy (if applicable)
624 -- if machHasEnergy == true then
625 -- ImpAPI.draw_line(detailsKeyColumn, detailsLine, (monX - detailsKeyColumn), colors.black, mon)
626 -- ImpAPI.CWrite(detailsKeyColumn, detailsLine, mon, "Energy: ", colors.orange)
627 -- ImpAPI.CWrite(detailsValueColumn, detailsLine, mon, tableMachines[i].Energy.."/"..tableMachines[i].MaxEnergy, colors.white)
628 -- detailsLine = detailsLine + 2
629 -- else
630 -- detailsLine = detailsLine + 3
631 -- end
632
633 -- -- Slot 1 Item
634 -- if invSlots > 0 then
635 -- ImpAPI.draw_line(detailsKeyColumn, detailsLine, (monX - detailsKeyColumn), colors.black, mon)
636 -- ImpAPI.CWrite(detailsKeyColumn, detailsLine, mon, tableMachines[i].slot1Name, colors.orange)
637 -- ImpAPI.CWrite(detailsValueColumn, detailsLine, mon, tableMachines[i].ItemInSlot1, colors.white)
638 -- detailsLine = detailsLine + 1
639
640 -- -- Slot 1 Qty
641 -- ImpAPI.draw_line(detailsKeyColumn, detailsLine, (monX - detailsKeyColumn), colors.black, mon)
642 -- ImpAPI.CWrite(detailsKeyColumn, detailsLine, mon, "Qty: ", colors.orange)
643 -- ImpAPI.CWrite(detailsValueColumn, detailsLine, mon, tableMachines[i].ItemQtyInSlot1, colors.white)
644 -- detailsLine = detailsLine + 2
645 -- end
646
647 -- if invSlots > 1 then
648 -- -- Slot 2 Item
649 -- ImpAPI.draw_line(detailsKeyColumn, detailsLine, (monX - detailsKeyColumn), colors.black, mon)
650 -- ImpAPI.CWrite(detailsKeyColumn, detailsLine, mon, tableMachines[i].slot2Name, colors.orange)
651 -- ImpAPI.CWrite(detailsValueColumn, detailsLine, mon, tableMachines[i].ItemInSlot2, colors.white)
652 -- detailsLine = detailsLine + 1
653
654 -- -- Slot 2 Qty
655 -- ImpAPI.draw_line(detailsKeyColumn, detailsLine, (monX - detailsKeyColumn), colors.black, mon)
656 -- ImpAPI.CWrite(detailsKeyColumn, detailsLine, mon, "Qty: ", colors.orange)
657 -- ImpAPI.CWrite(detailsValueColumn, detailsLine, mon, tableMachines[i].ItemQtyInSlot2, colors.white)
658 -- detailsLine = detailsLine + 2
659 -- end
660
661 -- if invSlots > 2 then
662 -- -- Slot 3 Item
663 -- ImpAPI.draw_line(detailsKeyColumn, detailsLine, (monX - detailsKeyColumn), colors.black, mon)
664 -- ImpAPI.CWrite(detailsKeyColumn, detailsLine, mon, tableMachines[i].slot3Name, colors.orange)
665 -- ImpAPI.CWrite(detailsValueColumn, detailsLine, mon, tableMachines[i].ItemInSlot3, colors.white)
666 -- detailsLine = detailsLine + 1
667
668 -- -- Slot 3 Qty
669 -- ImpAPI.draw_line(detailsKeyColumn, detailsLine, (monX - detailsKeyColumn), colors.black, mon)
670 -- ImpAPI.CWrite(detailsKeyColumn, detailsLine, mon, "Qty: ", colors.orange)
671 -- ImpAPI.CWrite(detailsValueColumn, detailsLine, mon, tableMachines[i].ItemQtyInSlot3, colors.white)
672 -- detailsLine = detailsLine + 2
673 -- end
674
675 --elseif clicked == false then
676 --ImpAPI.draw_line(detailsKeyColumn, detailsLine, (monX - detailsKeyColumn), colors.black, mon)
677 --ImpAPI.CWrite(detailsKeyColumn, detailsLine, mon, "No Machine Selected", colors.red)
678 --detailsLine = detailsLine + 1
679 --end
680
681
682
683
684
685
686
687 --ImpAPI.draw_line(1,line+1, 39, colors.black, mon)
688
689
690
691 line = line + 1
692
693 end
694
695 -- Details line
696 for l = line,(monY -1) do
697 if altColorSwitch == 0 then
698 ImpAPI.draw_line(1, l, monX, altColor1, mon)
699 altColorSwitch = 1
700 else
701 ImpAPI.draw_line(1, l, monX, altColor2, mon)
702 altColorSwitch = 0
703 end
704 end
705-----------------------------------------------------------------------------------------------------------------
706-- Watch for mouse events
707-----------------------------------------------------------------------------------------------------------------
708 local myTimer = os.startTimer(.2)
709
710 local exitConditionVariable = false
711
712 while not exitConditionVariable do
713 myEvent = {os.pullEvent()}
714 if myEvent[1] == "monitor_touch" then
715 xClicked=myEvent[3]
716 yClicked=myEvent[4]
717 --ImpAPI.CWrite(1,27,mon,ImpAPI.tablelength(tableMachines) + 2,colors.orange)
718 if yClicked > 2 and yClicked <= (ImpAPI.tablelength(tableMachines) + 2) then
719 clicked = true
720 clickedLine = yClicked
721 else
722 clicked = false
723 end
724
725
726 --button.checkxy(myEvent[3],myEvent[4])
727 elseif myEvent[1] == "timer" and myEvent[2] == myTimer then
728 exitConditionVariable = true
729 end
730 end
731
732 -- Debug for monitor size
733 if debugMode then
734 mon.setCursorPos(1,line)
735 mon.write("S: "..sizeXY)
736 line = line + 1
737 mon.setCursorPos(1,line)
738 mon.write("H: "..monY)
739 line = line + 1
740 mon.setCursorPos(1,line)
741 mon.write("W: "..monX)
742 end
743 else
744 mon.clear()
745 ImpAPI.draw_line(1,1,monX, colors.red, mon)
746 mon.setCursorPos(1,1)
747 mon.setTextColor(colors.white)
748 mon.write("Monitor Too Small")
749 ImpAPI.draw_line(1,2,monX, colors.black, mon)
750 mon.setCursorPos(1,3)
751 mon.write("Please increase the")
752 mon.setCursorPos(1,4)
753 mon.write("size of your monitor")
754 mon.setCursorPos(1,5)
755 mon.write(renderReason)
756 end
757
758 -- Reset line variable
759 line = 1
760
761 -- Loop timer
762 sleep(.25)
763end
764
765-----------------------------------------------------------------------------------------------------------------
766-- End of Program
767-----------------------------------------------------------------------------------------------------------------