Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---- Glasses - By MysteryDash ----
- --
- GlassesLocation = "top" -- Can be top, left, right, front, back, bottom
- RednetSide = "back"
- BroadcastPrefix = "Orangina "
- --
- Glasses = peripheral.wrap(GlassesLocation)
- if (Glasses == nil) then
- print("Could not find Terminal Glasses Bridge")
- error()
- end
- rednet.open(RednetSide)
- if (not rednet.isOpen(RednetSide)) then
- error()
- end
- -- Setup
- Colors = {}
- Colors.Gray = 0xE0E0E0
- Colors.LightGray = 0xA5A5A5
- Colors.TextGray = 0x818181
- Colors.Orange = 0xFF5100
- Colors.DarkOrange = 0xFF2A00
- Colors.Red = 0xFF3333
- Colors.Blue = 0x7DD2E4
- Colors.Yellow = 0xFFFF4D
- Colors.Green = 0x4DFF4D
- Colors.Rain = 0x2E679F
- Glasses.clear()
- MainBox = Glasses.addBox(20, 20, 1, 48, Colors.Gray, 0.7)
- OutlineT = Glasses.addBox(18, 18 ,2, 2, Colors.Blue, 0.7)
- OutlineB = Glasses.addBox(18, 68, 2, 2, Colors.Blue, 0.7)
- -- Start Animation
- for i = 0, 17 do
- MainBox.setWidth(i * 8)
- OutlineT.setWidth(i * 8 + 4)
- OutlineB.setWidth(i * 8 + 4)
- sleep(0.01)
- end
- -- Texts
- Header = Glasses.addText(30, 25, "", Colors.TextGray)
- Header.setText("MysteryDash's Glasses")
- MainText = Glasses.addText(60, 35, "", Colors.Blue)
- MainText.setScale(2)
- SecondText = Glasses.addText(40, 55, "", Colors.Blue)
- -- Functions
- function PrepareText(s) -- Trim a text and remove spaces and lower it
- return ((s:match("^%s*(.*)%s*$")):gsub("%s+", "")):lower()
- end
- function PutSecondText(text)
- SecondText.setText(text)
- SecondText.setX((((13)-(#text/2))*6)+20)
- sleep(1)
- SecondText.setText("")
- end
- -- Threads
- local function TimeUpdate()
- while true do
- 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
- sleep(.5)
- end
- end
- local function GlassesUpdate()
- while true do
- e, Message = os.pullEvent()
- if e == "chat_command" then
- Message = PrepareText(Message)
- if (not (string.find(Message, PrepareText("Portal X")) == nil)) then
- if (not (string.find(Message, PrepareText("Enable")) == nil)) then
- rednet.broadcast(BroadcastPrefix .. "Portal X Enable")
- PutSecondText("Portal X Enabling...")
- elseif (not (string.find(Message, PrepareText("Disable")) == nil)) then
- rednet.broadcast(BroadcastPrefix .. "Portal X Disable")
- PutSecondText("Portal X Disabling...")
- else
- -- NOTHING HERE FOR THE MOMENT
- end
- elseif (not (string.find(Message, PrepareText("ME")) == nil)) then
- if (not (string.find(Message, PrepareText("Enable")) == nil)) then
- rednet.broadcast(BroadcastPrefix .. "ME Enable")
- PutSecondText("ME Enabling...")
- elseif (not (string.find(Message, PrepareText("Disable")) == nil)) then
- rednet.broadcast(BroadcastPrefix .. "ME Disable")
- PutSecondText("ME Disabling...")
- else
- -- NOTHING HERE FOR THE MOMENT
- end
- elseif (not (string.find(Message, PrepareText("Glasses")) == nil)) then
- if (not (string.find(Message, PrepareText("Reset")) == nil)) then
- os.reboot()
- else
- -- NOTHING HERE FOR THE MOMENT
- end
- end
- print("Chat Command : " .. Message)
- end
- end
- end
- parallel.waitForAll(TimeUpdate, GlassesUpdate)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement