Advertisement
Guest User

Untitled

a guest
Sep 18th, 2014
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.33 KB | None | 0 0
  1. ---- Glasses - By MysteryDash ----
  2.  
  3. --
  4.  
  5. GlassesLocation = "top" -- Can be top, left, right, front, back, bottom
  6. RednetSide = "back"
  7. BroadcastPrefix = "Orangina "
  8.  
  9. --
  10.  
  11. Glasses = peripheral.wrap(GlassesLocation)
  12.  
  13. if (Glasses == nil) then
  14. print("Could not find Terminal Glasses Bridge")
  15. error()
  16. end
  17.  
  18. rednet.open(RednetSide)
  19. if (not rednet.isOpen(RednetSide)) then
  20. error()
  21. end
  22.  
  23. -- Setup
  24.  
  25. Colors = {}
  26. Colors.Gray = 0xE0E0E0
  27. Colors.LightGray = 0xA5A5A5
  28. Colors.TextGray = 0x818181
  29. Colors.Orange = 0xFF5100
  30. Colors.DarkOrange = 0xFF2A00
  31. Colors.Red = 0xFF3333
  32. Colors.Blue = 0x7DD2E4
  33. Colors.Yellow = 0xFFFF4D
  34. Colors.Green = 0x4DFF4D
  35. Colors.Rain = 0x2E679F
  36.  
  37. Glasses.clear()
  38.  
  39. MainBox = Glasses.addBox(20, 20, 1, 48, Colors.Gray, 0.7)
  40. OutlineT = Glasses.addBox(18, 18 ,2, 2, Colors.Blue, 0.7)
  41. OutlineB = Glasses.addBox(18, 68, 2, 2, Colors.Blue, 0.7)
  42.  
  43. -- Start Animation
  44.  
  45. for i = 0, 17 do
  46. MainBox.setWidth(i * 8)
  47. OutlineT.setWidth(i * 8 + 4)
  48. OutlineB.setWidth(i * 8 + 4)
  49. sleep(0.01)
  50. end
  51.  
  52. -- Texts
  53.  
  54. Header = Glasses.addText(30, 25, "", Colors.TextGray)
  55. Header.setText("MysteryDash's Glasses")
  56.  
  57. MainText = Glasses.addText(60, 35, "", Colors.Blue)
  58. MainText.setScale(2)
  59.  
  60. SecondText = Glasses.addText(40, 55, "", Colors.Blue)
  61.  
  62. -- Functions
  63.  
  64. function PrepareText(s) -- Trim a text and remove spaces and lower it
  65. return ((s:match("^%s*(.*)%s*$")):gsub("%s+", "")):lower()
  66. end
  67.  
  68. function PutSecondText(text)
  69. SecondText.setText(text)
  70. SecondText.setX((((13)-(#text/2))*6)+20)
  71. sleep(1)
  72. SecondText.setText("")
  73. end
  74.  
  75. -- Threads
  76.  
  77. local function TimeUpdate()
  78. while true do
  79. MainText.setText(string.format("%02d:%02d", math.floor(os.time() * 50 / 60), (os.time() * 50 / 60 - math.floor(os.time() * 50 / 60)) * 60)) -- Fully made by MysteryDash
  80. sleep(.5)
  81. end
  82. end
  83.  
  84. local function GlassesUpdate()
  85. while true do
  86. e, Message = os.pullEvent()
  87. if e == "chat_command" then
  88. Message = PrepareText(Message)
  89. if (not (string.find(Message, PrepareText("Portal X")) == nil)) then
  90. if (not (string.find(Message, PrepareText("Enable")) == nil)) then
  91. rednet.broadcast(BroadcastPrefix .. "Portal X Enable")
  92. PutSecondText("Portal X Enabling...")
  93. elseif (not (string.find(Message, PrepareText("Disable")) == nil)) then
  94. rednet.broadcast(BroadcastPrefix .. "Portal X Disable")
  95. PutSecondText("Portal X Disabling...")
  96. else
  97. -- NOTHING HERE FOR THE MOMENT
  98. end
  99. elseif (not (string.find(Message, PrepareText("ME")) == nil)) then
  100. if (not (string.find(Message, PrepareText("Enable")) == nil)) then
  101. rednet.broadcast(BroadcastPrefix .. "ME Enable")
  102. PutSecondText("ME Enabling...")
  103. elseif (not (string.find(Message, PrepareText("Disable")) == nil)) then
  104. rednet.broadcast(BroadcastPrefix .. "ME Disable")
  105. PutSecondText("ME Disabling...")
  106. else
  107. -- NOTHING HERE FOR THE MOMENT
  108. end
  109. elseif (not (string.find(Message, PrepareText("Glasses")) == nil)) then
  110. if (not (string.find(Message, PrepareText("Reset")) == nil)) then
  111. os.reboot()
  112. else
  113. -- NOTHING HERE FOR THE MOMENT
  114. end
  115. end
  116. print("Chat Command : " .. Message)
  117. end
  118. end
  119. end
  120.  
  121. parallel.waitForAll(TimeUpdate, GlassesUpdate)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement