davedumas0

opencomputers robotControll_II

Feb 11th, 2023 (edited)
1,131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 27.22 KB | Gaming | 0 0
  1. -- Require necessary libraries
  2. local os = require("os")
  3. local computer = require("computer")
  4. local term = require("term")
  5. local filesystem = require("filesystem")
  6. local component = require("component")
  7. local keyboard = require("keyboard")
  8. local event = require("event")
  9. local serialization = require("serialization")
  10. local gpu = component.gpu
  11. local modem = component.modem
  12. local robotNavButtons = {}
  13. local robotActionsButtons = {}
  14.  
  15.  
  16. -- Minecraft colors
  17. colors_white = 0xffffff
  18. colors_orange = 0xff6600
  19. colors_magenta = 0xff00ff
  20. colors_lightblue = 0x0099ff
  21. colors_yellow = 0xffff00
  22. colors_lime = 0x00ff00
  23. colors_pink = 0xff3399
  24. colors_gray = 0x737373
  25. colors_lightgray = 0xa5a5a5
  26. colors_silver = 0xc0c0c0
  27. colors_cyan = 0x169c9d
  28. colors_purple = 0x8932b7
  29. colors_blue = 0x3c44a9
  30. colors_brown = 0x825432
  31. colors_green = 0x5d7c15
  32. colors_red = 0xb02e26
  33. colors_lightred = 0xffcccb
  34. colors_lightorange = 0xbd8817
  35. colors_black = 0x000000
  36.  
  37.  
  38. -- UUIDs for OpenComputers screens
  39. primaryScreen = "b20d3b1e-87ed-4f8a-941e-26dc440344f8"
  40. secondaryScreen = "2db16f67-86c1-404d-be3d-61894134f13d"
  41.  
  42.  
  43. leahBot = "933160e0-1a85-4cb0-a91d-d786fb02462f"
  44. -- Initial position of the robot in Minecraft world
  45. robotPos = {}
  46. robotPos.x = 0
  47. robotPos.y = 0
  48. robotPos.z = 0
  49.  
  50. -- Open the modem on channel 6 for communication
  51. modem.open(6)
  52.  
  53.  
  54.  
  55. -- ╔══════════════════════════════════════════╗ --
  56. -- ║      ╭─────╮  IU FUNCTIONS  ╭─────╮      ║ --
  57. -- ╚══════════════════════════════════════════╝ --
  58.  
  59.  
  60. -- Set the background color of the GPU
  61. function setBgColor (color)
  62.   gpu.setBackground(color)
  63. end
  64.  
  65. -- Set the foreground color of the GPU
  66. function setFgColor (color)
  67.   gpu.setForeground(color)
  68. end
  69.  
  70. -- Fill a specified rectangular area on the GPU with spaces
  71. function renderLine(posX, posY, sizeX, sizeY)
  72.   gpu.fill(posX, posY, sizeX, sizeY, " ")
  73. end
  74.  
  75. -- Set the position of the terminal cursor
  76. function setCursorPos (posX, posY)
  77.   term.setCursor(posX, posY)
  78. end
  79.  
  80. -- Write text to the terminal
  81. function renderText(text)
  82.   term.write(text)
  83. end
  84.  
  85. -- Print text to the console
  86. function testFunction (text)
  87.   print(text)
  88. end
  89.  
  90. -- Bind the GPU to a different screen
  91. function switchScreens(screen)
  92.   gpu.bind(screen, false)
  93. end
  94.  
  95.  
  96.  
  97.  
  98. -- Function that draws a progress bar on a terminal screen in OpenComputers
  99. function draw_ProgressBar(orientation, posX, posY, sizeX, sizeY, maxValue, value, bgColor, barColor, showValue)
  100.   -- Calculate the size of the bar based on the value and maxValue arguments
  101.   local barSize = orientation == 1 and sizeX * (value / maxValue) or sizeY * (value / maxValue)
  102.   -- String to display the value below the bar
  103.   local valueText = value .. "/" .. maxValue
  104.   -- Length of the valueText string
  105.   local valueTextLength = #valueText
  106.  
  107.   -- Set the background color to bgColor
  108.   setBgColor(bgColor)
  109.   -- Render a box around the bar
  110.   renderLine(posX - 1, posY - 1, sizeX + 2, sizeY + 2)
  111.  
  112.   if showValue then
  113.     -- Draw the bar inside a box
  114.     -- Set the background color of the box to colors_lightgray
  115.     setBgColor(colors_lightgray)
  116.     renderLine(posX, posY, sizeX, sizeY)
  117.     -- Set the bar color to barColor
  118.     setBgColor(barColor)
  119.     -- Render the bar based on orientation
  120.     if orientation == 1 then
  121.       renderLine(posX, posY, math.floor(barSize), sizeY)
  122.     else
  123.       renderLine(posX, posY + sizeY - math.floor(barSize), sizeX, math.floor(barSize))
  124.     end
  125.  
  126.     -- Display the value below the bar
  127.     -- Set the cursor position to center the valueText
  128.     setCursorPos(posX + (sizeX / 2) - valueTextLength / 2, posY + sizeY + 1)
  129.     -- Set the background color to bgColor
  130.     setBgColor(bgColor)
  131.     -- Set the text color to colors_lime
  132.     setFgColor(colors_lime)
  133.     renderText(valueText)
  134.   else
  135.     -- Draw the bar directly on the screen
  136.     setBgColor(barColor)
  137.     if orientation == 1 then
  138.       renderLine(posX, posY, math.floor(barSize), sizeY)
  139.     else
  140.       renderLine(posX, posY + sizeY - math.floor(barSize), sizeX, math.floor(barSize))
  141.     end
  142.   end
  143. end
  144.  
  145.  
  146. -- ╔══════════════════════════════════════════╗ --
  147. -- ║      ╰─────╯  IU FUNCTIONS  ╰─────╯      ║ --
  148. -- ╚══════════════════════════════════════════╝ --
  149.  
  150.  
  151.  
  152.  
  153. -- ╔══════════════════════════════════════════╗ --
  154. -- ║    ╭─────╮ BUTTON FUNCTIONS  ╭─────╮     ║ --
  155. -- ╚══════════════════════════════════════════╝ --
  156.  
  157.  
  158. -- Check for button presses
  159. function buttonCheck(posX, posY, buttonTable)
  160.   -- t is a flag to keep track of button presses
  161.   local t = false
  162.  
  163.   -- Loop through all buttons in the buttonTable
  164.   for i = 1, #buttonTable do
  165.     -- Check if the touch event is within the bounds of the button
  166.     local buttonPosX = posX >= buttonTable[i].posX and posX <= buttonTable[i].posX + buttonTable[i].sizeX
  167.     local buttonPosY = posY >= buttonTable[i].posY and posY <= buttonTable[i].posY + buttonTable[i].sizeY
  168.    
  169.     -- If the touch event is within the bounds of the button
  170.     if buttonPosX and buttonPosY then
  171.       -- If the flag t is not set
  172.       if not t then
  173.         -- Set the flag t to true
  174.         t = true
  175.        
  176.         -- Call the function stored in the button's `func` field and pass it the data stored in the `func_DATA` field
  177.         buttonTable[i].func(buttonTable[i].func_DATA)
  178.       end
  179.     else
  180.       -- If the touch event is not within the bounds of the button, set the flag t to false
  181.       t = false
  182.     end
  183.   end
  184. end
  185.  
  186.  
  187. -- function to draw buttons
  188. -- input: buttonTable - table containing all the button objects to be drawn
  189. function drawButtons(buttonTable)
  190.   for i = 1, #buttonTable do
  191.     -- check if the sizeOverride property is set to true
  192.     if buttonTable[i].sizeOverride then
  193.       -- set the background color of the button
  194.       setBgColor(buttonTable[i].buttonColor)
  195.       -- draw the button with the specified X, Y, sizeX, and sizeY values
  196.       renderLine(buttonTable[i].posX, buttonTable[i].posY, buttonTable[i].sizeX, buttonTable[i].sizeY)
  197.       -- set the cursor position within the button
  198.       setCursorPos(buttonTable[i].posX+1, buttonTable[i].posY+1)
  199.       -- set the text color of the button label
  200.       setFgColor(buttonTable[i].textColor)
  201.       -- render the button label
  202.       renderText(buttonTable[i].label)
  203.     else
  204.       -- set the background color of the button
  205.       setBgColor(buttonTable[i].buttonColor)
  206.       -- draw the button with the specified X, Y, and length of the label + 2
  207.       renderLine(buttonTable[i].posX, buttonTable[i].posY, string.len(buttonTable[i].label)+2, 3)
  208.       -- set the cursor position within the button
  209.       setCursorPos(buttonTable[i].posX+1, buttonTable[i].posY+1)
  210.       -- set the text color of the button label
  211.       setFgColor(buttonTable[i].textColor)
  212.       -- render the button label
  213.       renderText(buttonTable[i].label)
  214.     end
  215.   end
  216. end
  217.  
  218. -- This function creates a new button object with the specified properties and adds it to the specified button table.
  219. -- The button object will contain the label, position, size, color information, and functions that will be triggered
  220. -- when the button is clicked.
  221.  
  222. function newButton(label, posX, posY, sizeX, sizeY, SizeOverride, textColor, buttonColor, func, func_DATA, buttonTable)
  223.   -- Create a new button object
  224.   local button = {}
  225.    button.label = label -- Label to display on the button
  226.    button.posX = posX -- X position of the button on the screen
  227.    button.posY = posY -- Y position of the button on the screen
  228.    button.sizeX = sizeX -- Width of the button
  229.    button.sizeY = sizeY -- Height of the button
  230.    button.sizeOverride = SizeOverride -- Boolean to indicate whether the size of the button should be overridden
  231.                                       -- (if set to true, the size will be determined by the sizeX and sizeY properties)
  232.    button.textColor = textColor -- Color of the label text
  233.    button.buttonColor = buttonColor -- Color of the button background
  234.    button.func = func -- Function to call when the button is clicked
  235.    button.func_DATA = func_DATA -- Data to pass to the function when the button is clicked
  236.    button.clicked = false -- Boolean to track whether the button has been clicked
  237.    
  238.    -- Add the button to the specified button table
  239.    table.insert(buttonTable, button)
  240. end
  241.  
  242.  
  243. -- ╔══════════════════════════════════════════╗ --
  244. -- ║    ╰─────╯ BUTTON FUNCTIONS  ╰─────╯     ║ --
  245. -- ╚══════════════════════════════════════════╝ --
  246.  
  247.  
  248.  
  249. -- Send a message to the robot in Minecraft
  250. function sendMsgToRobot (msg)
  251.   -- Open channel 5 on the modem and set the strength to 255
  252.   modem.open(5)
  253.   modem.setStrength(255)
  254.  
  255.   -- Broadcast the message on channel 5
  256.  
  257.   modem.send(leahBot, 5, msg)
  258.  
  259.   -- Close channel 5 on the modem and update the console
  260.   modem.close(5)
  261.   updateConsole_01("sending command:"..msg)
  262. end
  263.  
  264.  
  265. -- Check for various events and handle them accordingly
  266. function checkForEvents()
  267.   -- Open channel 5 on the modem
  268.   modem.open(5)
  269.  
  270.   -- Wait for the next event to occur and store the event information in eventData
  271.   local eventData = {event.pull(0.1)}
  272.  
  273.   -- Check the type of event
  274.   if eventData[1] == "key_down" then
  275.     -- Handle keyboard events
  276.     -- eventData[2] will contain the ASCII value of the key that was pressed
  277.  
  278.   elseif eventData[1] == "touch" then
  279.     -- Handle touch events
  280.     -- eventData[3] and eventData[4] will contain the X and Y coordinates of the touch event, respectively
  281.  
  282.     if eventData[2] == primaryScreen then
  283.      
  284.       buttonCheck(eventData[3], eventData[4], robotNavButtons)
  285.        buttonCheck(eventData[3], eventData[4], robotActionsButtons)
  286.         buttonCheck(eventData[3], eventData[4], console_01_Buttons)
  287.          buttonCheck(eventData[3], eventData[4], console_02_Buttons)
  288.     end
  289.  
  290.   elseif eventData[1] == "modem_message" then
  291.     -- Handle modem message events
  292.     -- eventData[6] will contain the message sent over the modem
  293.     local message = serialization.unserialize(eventData[6])
  294.     if type(message) == "table" then
  295.       updateConsole_02(message[1].label)
  296.     else
  297.       updateConsole_02(message)
  298.     end
  299.     --updateConsole_02(serialization.unserialize(eventData[6]))
  300.     -- Wait for 0.3 seconds
  301.     os.sleep(0.3)
  302.   end
  303.  
  304.   -- Close channel 5 on the modem
  305.   modem.close(5)
  306.  
  307.   -- Return true to continue checking for events
  308.   return true
  309. end
  310.  
  311.  
  312.  
  313. -- ╔══════════════════════════════════════════╗ --
  314. -- ║      ╭─────╮   CONSOLE_01   ╭─────╮      ║ --
  315. -- ╚══════════════════════════════════════════╝ --
  316.  
  317.  
  318.  
  319. -- Initialize the first console panel
  320. function init_Consol_01 ()
  321.   console_01_posX = 5
  322.   console_01_posY = 32
  323.   console_01_sizeX = 40
  324.   console_01_sizeY = 15
  325.   console_01_Buttons = {}
  326.   console_01_contents = {}
  327.  
  328. end
  329.  
  330.  
  331. -- Function to draw the first console UI
  332. function drawConsole_01()
  333.   -- Set the background color to gray
  334.   setBgColor(colors_gray)
  335.   -- Draw a line for the console using the specified position, size and color
  336.   renderLine(console_01_posX, console_01_posY, console_01_sizeX, console_01_sizeY)
  337.   -- Set the background color to black
  338.   setBgColor(colors_black)
  339.   -- Draw a line for the contents of the console using the specified position, size and color
  340.   renderLine(console_01_posX+1, console_01_posY+1, console_01_sizeX-2, console_01_sizeY-2)
  341.   -- Set the text color to white
  342.   setFgColor(colors_white)
  343.   -- Set the background color to gray
  344.   setBgColor(colors_gray)
  345.   -- Set the cursor position to the center of the top of the console
  346.   setCursorPos(console_01_posX+console_01_sizeX/2-string.len("console 01")/2, console_01_posY)
  347.   -- Write the label "console 01"
  348.   renderText("console 01")
  349.   -- Create a "clear" button for the console
  350.   newButton("clear", console_01_posX, console_01_posY+console_01_sizeY, string.len("clear")+2, 3, true, colors_white, colors_lightblue, clearConsole_01, _, console_01_Buttons)
  351.   -- Draw all buttons for the console
  352.   drawButtons(console_01_Buttons)
  353. end
  354.  
  355.  
  356. function updateConsole_01(text)
  357.   -- Check if the number of lines in the console is less than the maximum number of lines that can be displayed
  358.   if #console_01_contents < console_01_sizeY-4 then
  359.     -- If there are fewer lines than the maximum number of lines, add the new text to the console_01_contents table
  360.     table.insert(console_01_contents, text)
  361.     -- Clear the background of the console
  362.     setBgColor(colors_black)
  363.     renderLine(console_01_posX+1, console_01_posY+1, console_01_sizeX-2, console_01_sizeY-2)
  364.     -- Loop through the console_01_contents table and display each line of text
  365.     for i = 1, #console_01_contents do
  366.       setCursorPos(console_01_posX+1, console_01_posY+1+i)
  367.       renderText(console_01_contents[i])
  368.     end
  369.   elseif #console_01_contents >= console_01_sizeY-4 then
  370.     -- If there are more lines than the maximum number of lines, add the new text to the console_01_contents table
  371.     table.insert(console_01_contents, text)
  372.     -- Remove the first line in the table
  373.     table.remove(console_01_contents, 1)
  374.     -- Clear the background of the console
  375.     setBgColor(colors_black)
  376.     renderLine(console_01_posX+1, console_01_posY+1, console_01_sizeX-2, console_01_sizeY-2)
  377.     -- Loop through the console_01_contents table and display each line of text
  378.     for i = 1, #console_01_contents do
  379.       setCursorPos(console_01_posX+1, console_01_posY+1+i)
  380.       renderText(console_01_contents[i])
  381.     end
  382.   end
  383. end
  384.  
  385.  
  386.  
  387.  
  388. -- Function to clear the contents of console 01
  389. function clearConsole_01 ()
  390.   -- Reset the contents of the console
  391.   console_01_contents = {}
  392.  
  393.   -- Set the background color to black and draw a line to clear the console
  394.   setBgColor(colors_black)
  395.   renderLine(console_01_posX+1, console_01_posY+1, console_01_sizeX-2, console_01_sizeY-2)
  396. end
  397.  
  398.  
  399. -- ╔══════════════════════════════════════════╗ --
  400. -- ║      ╰─────╯   CONSOLE_01   ╰─────╯      ║ --
  401. -- ╚══════════════════════════════════════════╝ --
  402.  
  403.  
  404. -- ╔══════════════════════════════════════════╗ --
  405. -- ║      ╭─────╮   CONSOLE_02   ╭─────╮      ║ --
  406. -- ╚══════════════════════════════════════════╝ --
  407.  
  408.  
  409.  
  410. -- Initialize the properties for the second console
  411. function init_Consol_02 ()
  412.   console_02_posX = 5
  413.   console_02_posY = 5
  414.   console_02_sizeX = 40
  415.   console_02_sizeY = 15
  416.   console_02_Buttons = {}
  417.   console_02_contents = {}
  418. end
  419.  
  420.  
  421. -- Function to draw the second console UI
  422. function drawConsole_02()
  423.   -- Set the background color to gray
  424.   setBgColor(colors_gray)
  425.   -- Draw a line for the console using the specified position, size and color
  426.   renderLine(console_02_posX, console_02_posY, console_02_sizeX, console_02_sizeY)
  427.   -- Set the background color to black
  428.   setBgColor(colors_black)
  429.   -- Draw a line for the contents of the console using the specified position, size and color
  430.   renderLine(console_02_posX+1, console_02_posY+1, console_02_sizeX-2, console_02_sizeY-2)
  431.   -- Set the text color to white
  432.   setFgColor(colors_white)
  433.   -- Set the background color to gray
  434.   setBgColor(colors_gray)
  435.   -- Set the cursor position to the center of the top of the console
  436.   setCursorPos(console_02_posX+console_02_sizeX/2-string.len("console 02")/2, console_02_posY)
  437.   -- Write the label "console 02"
  438.   renderText("console 02")
  439.   -- Create a "clear" button for the console
  440.   newButton("clear", console_02_posX, console_02_posY+console_02_sizeY, string.len("clear")+2, 3, true, colors_white, colors_lightblue, clearConsole_02, _, console_02_Buttons)
  441.   -- Draw all buttons for the console
  442.   drawButtons(console_02_Buttons)
  443. end
  444.  
  445.  
  446. -- Function to update the contents of the second console
  447. function updateConsole_02(text)
  448.   -- If the number of contents in the console is less than the size of the console minus 4
  449.   if #console_02_contents < console_02_sizeY-4 then
  450.     -- Add the new text to the contents of the console
  451.     table.insert(console_02_contents, text)
  452.     -- Set the background color to black
  453.     setBgColor(colors_black)
  454.     -- Draw a line for the contents of the console using the specified position, size and color
  455.     renderLine(console_02_posX+1, console_02_posY+1, console_02_sizeX-2, console_02_sizeY-2)
  456.     -- Loop through all the contents of the console
  457.     for i = 1, #console_02_contents do
  458.       -- Set the cursor position to the specified position
  459.       setCursorPos(console_02_posX+1, console_02_posY+1+i)
  460.       -- Write the contents of the console
  461.       renderText(console_02_contents[i])
  462.     end
  463.   -- If the number of contents in the console is equal to or greater than the size of the console minus 4
  464.   elseif #console_02_contents >= console_02_sizeY-4 then
  465.     -- Add the new text to the contents of the console
  466.     table.insert(console_02_contents, text)
  467.     -- Remove the first content from the console
  468.     table.remove(console_02_contents, 1)
  469.     -- Set the background color to black
  470.     setBgColor(colors_black)
  471.     -- Draw a line for the contents of the console using the specified position, size and color
  472.     renderLine(console_02_posX+1, console_02_posY+1, console_02_sizeX-2, console_02_sizeY-2)
  473.     -- Loop through all the contents of the console
  474.     for i = 1, #console_02_contents do
  475.       -- Set the cursor position to the specified position
  476.       setCursorPos(console_02_posX+1, console_02_posY+1+i)
  477.       -- Write the contents of the console
  478.       renderText(console_02_contents[i])
  479.     end
  480.   end
  481. end
  482.  
  483. -- Function to clear the contents of the second console
  484. function clearConsole_02 ()
  485.   -- Reset the contents of the console to an empty table
  486.   console_02_contents = {}
  487.   -- Set the background color to black
  488.   setBgColor(colors_black)
  489.   -- Draw a line for the contents of the console using the specified position, size and color
  490.   renderLine(console_02_posX+1, console_02_posY+1, console_02_sizeX-2, console_02_sizeY-2)
  491. end
  492.  
  493. -- ╔══════════════════════════════════════════╗ --
  494. -- ║      ╰─────╯   CONSOLE_02   ╰─────╯      ║ --
  495. -- ╚══════════════════════════════════════════╝ --
  496.  
  497. -- ╔══════════════════════════════════════════╗ --
  498. -- ║   ╭─────╮   NAVIGATION_PANEL   ╭─────╮   ║ --
  499. -- ╚══════════════════════════════════════════╝ --
  500.  
  501. -- Draw the navigation panel for the robot in Minecraft
  502. function drawRobotNavPanel()
  503.   -- Variables for the panel's position, size, and background color
  504.   local panelX = 123
  505.   local panelY = 40
  506.   local panelSizeX = 31
  507.   local panelSizeY = 9
  508.   local panel_BGColor = colors_gray
  509.  
  510.   -- Set the background color of the panel and render a rectangular area on the GPU
  511.   setBgColor(panel_BGColor)
  512.   renderLine(panelX, panelY, panelSizeX, panelSizeY)
  513.  
  514.   -- Set the cursor position, background color, and foreground color and render text
  515.   setCursorPos(panelX + panelSizeX / 2 - string.len("navigation controls")/2, panelY - 1)
  516.   setBgColor(colors_black)
  517.   setFgColor(colors_orange)
  518.   renderText("navigation controls")
  519.  
  520.   -- Create several navigation buttons and add them to the robotNavButtons table
  521.   newButton("NAV_FWD", panelX + 11, panelY + 1, 9, 3, true, colors_lightblue, colors_white, sendMsgToRobot, "FWD", robotNavButtons)
  522.   newButton("NAV_LFT", panelX + 1, panelY + 1, 9, 3, true, colors_lightblue, colors_white, sendMsgToRobot, "LFT", robotNavButtons)
  523.   newButton("NAV_RHT", panelX + 21, panelY + 1, 9, 3, true, colors_lightblue, colors_white, sendMsgToRobot, "RHT", robotNavButtons)
  524.   newButton("NAV_UPW", panelX + 1, panelY + 5, 9, 3, true, colors_lightblue, colors_white, sendMsgToRobot, "UP", robotNavButtons)
  525.   newButton("NAV_DWN", panelX + 21, panelY + 5, 9, 3, true, colors_lightblue, colors_white, sendMsgToRobot, "DWN", robotNavButtons)
  526.   newButton("NAV_BWD", panelX + 11, panelY + 5, 9, 3, true, colors_lightblue, colors_white, sendMsgToRobot, "BWD", robotNavButtons)
  527.  
  528.   -- Render the navigation buttons on the GPU
  529.   drawButtons(robotNavButtons)
  530. end
  531.  
  532. -- ╔══════════════════════════════════════════╗ --
  533. -- ║   ╰─────╯   NAVIGATION_PANEL   ╰─────╯   ║ --
  534. -- ╚══════════════════════════════════════════╝ --
  535.  
  536. -- ╔══════════════════════════════════════════╗ --
  537. -- ║     ╭─────╮   ACTIONS_PANEL   ╭─────╮    ║ --
  538. -- ╚══════════════════════════════════════════╝ --
  539.  
  540.  
  541.  
  542. -- Draw the actions panel for the robot in Minecraft
  543. function drawRobotActionsPanel()
  544.   -- Variables for the panel's position, size, and background color
  545.   local panelX = 123
  546.   local panelY = 25
  547.   local panelSizeX = 22
  548.   local panelSizeY = 13
  549.   local panel_BGColor = colors_gray
  550.  
  551.   -- Set the background color of the panel and render a rectangular area on the GPU
  552.   setBgColor(panel_BGColor)
  553.   renderLine(panelX, panelY, panelSizeX, panelSizeY)
  554.  
  555.   -- Set the cursor position, background color, and foreground color and render text
  556.   setCursorPos(panelX + panelSizeX / 2 - string.len("action controls")/2, panelY - 1)
  557.   setBgColor(colors_black)
  558.   setFgColor(colors_orange)
  559.   renderText("action controls")
  560.  
  561.   -- Create several action buttons and add them to the robotActionsButtons table
  562.   newButton("DCT_UPW", panelX + 1, panelY + 1, string.len("DCT_UPW")+2, 3, true, colors_lightblue, colors_white, sendMsgToRobot, "DCT_UPW", robotActionsButtons)
  563.   newButton("DCT_FWD", panelX + 1, panelY + 5, string.len("DCT_FWD")+2, 3, true, colors_lightblue, colors_white, sendMsgToRobot, "DCT_FWD", robotActionsButtons)
  564.   newButton("DCT_DWD", panelX + 1, panelY + 5 + 4, (string.len("DCT_FWD")+2), 3, true, colors_lightblue, colors_white, sendMsgToRobot, "DCT_DWD", robotActionsButtons)
  565.   newButton("USE_FWD", panelX + 11, panelY + 5, (string.len("DCT_FWD")+2), 3, true, colors_lightblue, colors_white, sendMsgToRobot, "USE_FWD", robotActionsButtons)
  566.   --newButton("GET_INV", panelX + 11, panelY + 1, (string.len("DCT_FWD")+2), 3, true, colors_lightblue, colors_white, sendMsgToRobot, "GET_INV", robotActionsButtons)
  567.   -- Render the action buttons on the GPU
  568.   drawButtons(robotActionsButtons)
  569. end
  570.  
  571. -- ╔══════════════════════════════════════════╗ --
  572. -- ║     ╰─────╯   ACTIONS_PANEL   ╰─────╯    ║ --
  573. -- ╚══════════════════════════════════════════╝ --
  574.  
  575.  
  576.  
  577. function drawInventoryPanel()
  578.   local panelX = 146
  579.   local panelY = 25
  580.   local panelSizeX = 13
  581.   local panelSizeY = 13
  582.   local panel_BGColor = colors_gray
  583.   setBgColor(panel_BGColor)
  584.   renderLine(panelX, panelY, panelSizeX, panelSizeY)
  585.  
  586. end
  587.  
  588.  
  589.  
  590.  
  591. function displayAspects()
  592.   local x = 2
  593.   local y = 2
  594.   local primalAspects = {
  595.     ["Aer"] = {aspect = "air", color = 0x87CEFA},
  596.     ["Terra"] = {aspect = "earth", color = 0x228B22},
  597.     ["Ignis"] = {aspect = "fire", color = 0xFF4500},
  598.     ["Aqua"] = {aspect = "water", color = 0x1E90FF},
  599.     ["Ordo"] = {aspect = "order", color = 0xF5DEB3},
  600.     ["Perditio"] = {aspect = "entropy", color = 0xA9A9A9}
  601.   }
  602.  
  603.   local compoundAspects = {
  604.     ["Alienis"] = {aspect = "strange", color = 0xFF00FF},
  605.     ["Arbor"] = {aspect = "tree", color = 0x228B22},
  606.     ["Bestia"] = {aspect = "beast", color = 0xA0522D},
  607.     ["Cognitio"] = {aspect = "knowledge", color = 0xFFD700},
  608.     ["Corpus"] = {aspect = "body", color = 0x8B008B},
  609.     ["Exanimis"] = {aspect = "dead", color = 0x696969},
  610.     ["Herba"] = {aspect = "plant", color = 0x228B22},
  611.     ["Humanus"] = {aspect = "man", color = 0xFF69B4},
  612.     ["Instrumentum"] = {aspect = "tool", color = 0xA9A9A9},
  613.     ["Lucrum"] = {aspect = "profit", color = 0xFFD700},
  614.     ["Machina"] = {aspect = "machine", color = 0xA9A9A9},
  615.     ["Metallum"] = {aspect = "Metal", color = 0xA9A9A9},
  616.     ["Mortuus"] = {aspect = "dead", color = 0x696969},
  617.     ["Praecantatio"] = {aspect = "magic", color = 0xFF00FF},
  618.     ["Sensus"] = {aspect = "sense", color = 0x00FF00},
  619.     ["Spiritus"] = {aspect = "spirit", color = 0x0000FF},
  620.     ["Vacuos"] = {aspect = "void", color = 0xA9A9A9},
  621.     ["Vitium"] = {aspect = "vice", color = 0x8B008B}
  622.   }
  623.     setBgColor(colors_lightgray)
  624.      renderLine(x, y, 158, 48)
  625.  
  626.     setBgColor(colors_black)
  627.      renderLine(x+1, y+1, 17, 6)
  628.  
  629.     setFgColor(colors_white)
  630.      setCursorPos(x+3, y)
  631.       renderText("Primal Aspects")
  632.  
  633.   for _, aspectData in pairs(primalAspects) do  
  634.     setFgColor(aspectData.color)
  635.      setCursorPos(x+3, y+1)
  636.       y = y + 1
  637.        renderText(aspectData.aspect)
  638.   end
  639. y = 10
  640.    setBgColor(colors_black)
  641.     renderLine(x+1, y, 19, 20)
  642.  
  643.  setFgColor(colors_white)
  644.   setCursorPos(x+3, y)
  645.    renderText("Compound Aspects")
  646.   for _, aspectData in pairs(compoundAspects) do
  647.     y = y+1
  648.       setFgColor(aspectData.color)
  649.        setCursorPos(x+3, y)
  650.         renderText(aspectData.aspect)
  651.    
  652.   end
  653. end
  654.  
  655.  
  656.  
  657.  
  658. switchScreens(primaryScreen)
  659. term.clear()
  660. -- Initialize the first console UI
  661. init_Consol_01 ()
  662. -- Initialize the second console UI
  663. init_Consol_02 ()
  664.  
  665. -- Draw the first console UI
  666. drawConsole_01()
  667. -- Draw the second console UI
  668. drawConsole_02()
  669.  
  670. -- Draw the navigation panel for the robot
  671. drawRobotNavPanel()
  672.  
  673. -- Draw the actions panel for the robot
  674. drawRobotActionsPanel()
  675.  
  676. drawInventoryPanel()
  677.  
  678. switchScreens(secondaryScreen)
  679. term.clear()
  680. displayAspects()
  681.  
  682. switchScreens(primaryScreen)
  683.  
  684.  
  685.  
  686.  
  687.  
  688. -- Continuously check for events
  689. while true do
  690.   -- Call the checkForEvents function to handle any incoming events
  691.   checkForEvents()
  692. end
  693.  
Add Comment
Please, Sign In to add comment