Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Little thing with some functions I like to use in my stuff.
- function printCenter(text)
- local w, _ = term.getSize()
- local _, y = term.getCursorPos()
- local x = math.max(math.floor((w / 2) - (#text / 2)), 0)
- term.setCursorPos(x, y)
- write(text)
- end
- function printFarRight(text)
- local w, _ = term.getSize()
- local _, h = term.getCursorPos()
- term.setCursorPos(w - #text, h)
- print(text)
- end
- function printSpecificX(text, x)
- local _, h = term.getCursorPos()
- term.setCursorPos(x, h)
- write(text)
- end
- function has_key(array, key)
- return array[key] ~= nil
- end
- function getTableSize(array)
- local count = 0
- for _, __ in pairs(array) do
- count = count + 1
- end
- return count
- end
- function deepEquals(t1, t2)
- local ty1 = type(t1)
- local ty2 = type(t2)
- if ty1 ~= ty2 then
- return false
- end
- -- non-table types can be directly compared
- if ty1 ~= "table" and ty2 ~= "table" then
- return t1 == t2
- end
- if getTableSize(t1) ~= getTableSize(t2) then
- return false
- end
- for k1, v1 in pairs(t1) do
- local v2 = t2[k1]
- if v2 == nil or not deepEquals(v1, v2) then
- return false
- end
- end
- for k2, v2 in pairs(t2) do
- local v1 = t1[k2]
- if v1 == nil or not deepEquals(v1, v2) then
- return false
- end
- end
- return true
- end
Add Comment
Please, Sign In to add comment