Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ImpShial API
- -- Version 0.2
- ---------------------------------------------------------------------------------------
- -- Tested on Computercraft version 1.58
- -- Minecraft version 1.6.4
- ---------------------------------------------------------------------------------------
- --
- -- NOTE: THIS IS A WORK IN PROGRESS
- --
- -- This code was written by Impshial and is free software:
- -- You can redistribute it and/or modify
- -- it under the terms of the GNU General Public License as published by
- -- the Free Software Foundation, either version 3 of the License, or
- -- (at your option) any later version.
- -- This program is distributed in the hope that it will be useful,
- -- but WITHOUT ANY WARRANTY; without even the implied warranty of
- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- -- GNU General Public License for more details.
- --
- -- See https://www.gnu.org/licenses/ for details
- --
- -- Pastebin for this program: https://pastebin.com/pwBMKNCb
- --
- ---------------------------------------------------------------------------------------
- -- Version notes:
- --
- -- Added Table functions
- ---------------------------------------------------------------------------------------
- --Finds a monitor on the network
- function monitorSearch()
- local names = peripheral.getNames()
- local i, name
- for i, name in pairs(names) do
- if peripheral.getType(name) == "monitor" then
- test = name
- return peripheral.wrap(name)
- else
- --return null
- end
- end
- end
- function getCentertextPos(text, mon)
- w, h = mon.getSize()
- mon.setCursorPos(math.floor((x - #text) / 2) + 1)
- end
- --Sorting function: Alpha
- function pairsByKeys (t, f)
- local a = {}
- for n in pairs(t) do table.insert(a, n) end
- table.sort(a, f)
- local i = 0 -- iterator variable
- local iter = function () -- iterator function
- i = i + 1
- if a[i] == nil then return nil
- else return a[i], t[a[i]]
- end
- end
- return iter
- end
- --Draw line on monitor
- function draw_line(x, y, length, color, monitor)
- monitor.setBackgroundColor(color)
- monitor.setCursorPos(x,y)
- monitor.write(string.rep(" ", length))
- end
- --Draw line in Terminal
- function draw_line_term(x, y, length, color)
- term.setBackgroundColor(color)
- term.setCursorPos(x,y)
- term.write(string.rep(" ", length))
- end
- -- Compact Monitor Write function
- function CWrite(col, row, monitor, text, color)
- color = color or colors.white
- monitor.setCursorPos(col,row)
- monitor.clearLine()
- monitor.setTextColor(color)
- monitor.write(text)
- end
- -- Compact Terminal Write function
- function CTWrite(col, row, text, color)
- color = color or colors.white
- term.setCursorPos(col,row)
- term.setTextColor(color)
- term.write(text)
- end
- -- Get number of items in a table
- function tablelength(T)
- local count = 0
- for _ in pairs(T) do count = count + 1 end
- return count
- end
Add Comment
Please, Sign In to add comment