bobmarley12345

ccenderchestcoloursetter

Oct 28th, 2020 (edited)
856
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. MonitorSide = "bottom"
  2. Monitor = term
  3.  
  4. function ClearMonitor()
  5.     Monitor.setTextColor(colours.black)
  6.     Monitor.setBackgroundColor(colours.black)
  7.     Monitor.clear()
  8.     Monitor.setCursorPos(1,1)
  9. end
  10.  
  11. function DrawText(xPos, yPos, text, textColour, backgroundColour)
  12.     Monitor.setBackgroundColor(backgroundColour)
  13.     Monitor.setTextColor(textColour)
  14.     Monitor.setCursorPos(xPos,yPos)
  15.     Monitor.write(text)
  16. end
  17.  
  18. function StringToColour(colourName)
  19.     if (colourName == "black"    ) then return colours.black     end
  20.     if (colourName == "red"      ) then return colours.red       end
  21.     if (colourName == "green"    ) then return colours.green     end
  22.     if (colourName == "brown"    ) then return colours.brown     end
  23.     if (colourName == "blue"     ) then return colours.blue      end
  24.     if (colourName == "purple"   ) then return colours.purple    end
  25.     if (colourName == "cyan"     ) then return colours.cyan      end
  26.     if (colourName == "lightgrey") then return colours.lightGrey end
  27.     if (colourName == "grey"     ) then return colours.grey      end
  28.     if (colourName == "pink"     ) then return colours.pink      end
  29.     if (colourName == "lime"     ) then return colours.lime      end
  30.     if (colourName == "yellow"   ) then return colours.yellow    end
  31.     if (colourName == "lightblue") then return colours.lightBlue end
  32.     if (colourName == "magenta"  ) then return colours.magenta   end
  33.     if (colourName == "orange"   ) then return colours.orange    end
  34.     if (colourName == "white"    ) then return colours.white
  35.     else return colours.white end
  36. end
  37.  
  38. function Main()
  39.     term.clear()
  40.     DrawText(1, 1,  "Avaliable Colours:", colours.white, colours.black)
  41.     DrawText(1, 2,  "black     "   , colours.white, colours.black     )
  42.     DrawText(1, 3,  "red       "   , colours.white, colours.red       )
  43.     DrawText(1, 4,  "green     "   , colours.white, colours.green     )
  44.     DrawText(1, 5,  "brown     "   , colours.white, colours.brown     )
  45.     DrawText(1, 6,  "blue      "   , colours.white, colours.blue      )
  46.     DrawText(1, 7,  "purple    "   , colours.white, colours.purple    )
  47.     DrawText(1, 8,  "cyan      "   , colours.white, colours.cyan      )
  48.     DrawText(1, 9,  "lightgrey "   , colours.white, colours.lightGrey )
  49.     DrawText(12, 2, "grey      "   , colours.white, colours.grey      )
  50.     DrawText(12, 3, "pink      "   , colours.white, colours.pink      )
  51.     DrawText(12, 4, "lime      "   , colours.white, colours.lime      )
  52.     DrawText(12, 5, "yellow    "   , colours.white, colours.yellow    )
  53.     DrawText(12, 6, "lightblue "   , colours.white, colours.lightBlue )
  54.     DrawText(12, 7, "magenta   "   , colours.white, colours.magenta   )
  55.     DrawText(12, 8, "orange    "   , colours.white, colours.orange    )
  56.     DrawText(12, 9, "white     "   , colours.black, colours.white     )
  57.  
  58.     DrawText(1, 10, "What colours should the chest be?", colours.white, colours.black)
  59.  
  60.     DrawText(1, 11, "Colour 1: ", colours.white, colours.black)
  61.     local colour1 = read()
  62.  
  63.     DrawText(1, 12, "Colour 2: ", colours.white, colours.black)
  64.     local colour2 = read()
  65.  
  66.     DrawText(1, 13, "Colour 3: ", colours.white, colours.black)
  67.     local colour3 = read()
  68.  
  69.     while true do
  70.         local chest = peripheral.wrap("left")
  71.         if (chest == nil) then
  72.             DrawText(1, 15, "Chest is not on the left.", colours.white, colours.red)
  73.         else
  74.             DrawText(1, 15, "Setting colours to ", colours.white, colours.green)
  75.             local actualColour1 = StringToColour(colour1)
  76.             local actualColour2 = StringToColour(colour2)
  77.             local actualColour3 = StringToColour(colour3)
  78.             DrawText(1, 16,  "     ", actualColour1, actualColour1)
  79.             DrawText(6, 16,  "     ", actualColour2, actualColour2)
  80.             DrawText(11, 16, "     ", actualColour3, actualColour3)
  81.             chest.setColours(actualColour1, actualColour2, actualColour3)
  82.         end
  83.  
  84.         sleep(0.5)
  85.     end
  86. end
  87.  
  88. Main()
RAW Paste Data