Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local System = os -- Used for System things like os.time() to System.time()
- local Screen = term -- Used for Screen thing on the turtle or computer like term.clear() to Screen.clear()
- local Per = peripheral -- Used shortcut for peripheral
- local Text = textutils -- Used shortcut for textilils
- local Pack = Text.serialize -- Makes a new command for packing ( shortcut used from local Text)
- local UnPack = Text.unserialize -- Makes a new command for unpacking ( shortcut used from local Text)
- local w, h = Screen.getSize()
- function getPerNames()
- local Data = Per.getNames()
- return Data
- end
- function FindDisk()
- SetColors(Screen, colors.white, colors.black)
- Screen.setCursorPos(math.floor((w - string.len("Finding Disk")) /2), (h-1))
- print("Finding Disk")
- SetColors(Screen, colors.black, colors.white)
- for i,name in pairs(Per.getNames()) do
- for j,method in pairs(Per.getMethods(name)) do
- if (method == 'isDiskPresent') then
- return name
- end
- end
- end
- end
- function FindModem()
- SetColors(Screen, colors.white, colors.black)
- Screen.setCursorPos(math.floor((w - string.len("Finding Modem")) /2), (h-1))
- print("Finding Modem")
- SetColors(Screen, colors.black, colors.white)
- for i,name in pairs(Per.getNames()) do
- for j,method in pairs(Per.getMethods(name)) do
- if (method == 'isWireless') then
- local M = Per.wrap(name)
- if M.isWireless() == false then
- return name
- end
- end
- end
- end
- end
- function FindWirelessModem()
- SetColors(Screen, colors.white, colors.black)
- Screen.setCursorPos(math.floor((w - string.len("Finding Wireless Modem")) /2), (h-1))
- print("Finding Wireless Modem")
- SetColors(Screen, colors.black, colors.white)
- for i,name in pairs(Per.getNames()) do
- for j,method in pairs(Per.getMethods(name)) do
- if (method == 'isWireless') then
- local M = Per.wrap(name)
- if (M.isWireless) then
- return name
- end
- end
- end
- end
- end
- function FindMonitor()
- SetColors(Screen, colors.white, colors.black)
- Screen.setCursorPos(math.floor((w - string.len("Finding Monitor")) /2), (h-1))
- print("Finding Monitor")
- SetColors(Screen, colors.black, colors.white)
- for i,name in pairs(Per.getNames()) do
- for j,method in pairs(Per.getMethods(name)) do
- if (method == 'clear') then
- return name
- end
- end
- end
- end
- function FindPrinter()
- SetColors(Screen, colors.white, colors.black)
- Screen.setCursorPos(math.floor((w - string.len("Finding Printer")) /2), (h-1))
- print("Finding Printer")
- SetColors(Screen, colors.black, colors.white)
- for i,name in pairs(Per.getNames()) do
- for j,method in pairs(Per.getMethods(name)) do
- if (method == 'newPage') then
- return name
- end
- end
- end
- end
- function FindSpeaker()
- SetColors(Screen, colors.white, colors.black)
- Screen.setCursorPos(math.floor((w - string.len("Finding Speaker")) /2), (h-1))
- print("Finding Speaker")
- SetColors(Screen, colors.black, colors.white)
- for i,name in pairs(Per.getNames()) do
- for j,method in pairs(Per.getMethods(name)) do
- if (method == 'playSound') then
- return name
- end
- end
- end
- end
- function DelFile(Path)
- if fs.exists(Path) then
- fs.delete(Path)
- end
- end
- function LoadFile(Path)
- if fs.exists(Path) then
- File = fs.open(Path, "r")
- local Data = UnPack(File.readAll())
- File.close()
- return Data
- end
- end
- function SaveFile(Path, For, Data)
- File = fs.open(Path, For)
- File.write(Pack(Data))
- File.close()
- end
- function SetColors(WhatScreen, Background, Text)
- WhatScreen.setBackgroundColor(Background)
- WhatScreen.setTextColor(Text)
- end
- function SetTitle(WhatScreen, text)
- w, h = WhatScreen.getSize()
- WhatScreen.setCursorPos((w-string.len(text))/2+1, 1)
- WhatScreen.write(text)
- end
- function PadString(sText, iLen)
- local iTextLen = string.len(sText)
- -- Too short, pad
- if (iTextLen < iLen) then
- local iDiff = iLen - iTextLen
- return(sText..string.rep(" ",iDiff))
- end
- -- Too long, trim
- if (iTextLen > iLen) then
- return(string.sub(sText,1,iLen))
- end
- -- Exact length
- return(sText)
- end
- function printCentered(WhatScreen,y,s)
- local x = math.floor((w - string.len(s)) /2)
- WhatScreen.setCursorPos(x,y)
- WhatScreen.clearLine()
- WhatScreen.write(s)
- end
- function printCenteredNC(WhatScreen,y,s)
- local x = math.floor((w - string.len(s)) /2)
- WhatScreen.setCursorPos(x,y)
- WhatScreen.write(s)
- end
- function printQuart(WhatScreen,y,s)
- WhatScreen.setCursorPos(1,y)
- WhatScreen.clearLine()
- WhatScreen.write(s)
- end
- function printThreeQuart(WhatScreen,y,s)
- local x = math.floor(w - string.len(s))
- WhatScreen.setCursorPos(x,y)
- WhatScreen.clearLine()
- WhatScreen.write(s)
- end
- function printThreeQuartNC(WhatScreen,y,s)
- local x = math.floor(w - string.len(s))
- WhatScreen.setCursorPos(x,y)
- WhatScreen.write(s)
- end
Advertisement
Add Comment
Please, Sign In to add comment