Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function clearPos(x, y, side)
- m = peripheral.wrap(side)
- m.setCursorPos(x,y)
- m.clearLine()
- end
- function appendString(side, color, text, clear, x, y)
- local m = peripheral.wrap(side)
- local a,b = m.getCursorPos()
- if x == 0 and y ~= 0 then
- m.setCursorPos(a,y)
- elseif x ~= 0 and y == 0 then
- -- set x position
- m.setCursorPos(x,b)
- elseif x ~= 0 and y ~= 0 then
- m.setCursorPos(x,y)
- elseif x == 0 and y == 0 then
- m.setCursorPos(a,b)
- end
- m.setTextColor(color)
- if clear == true then
- m.clearLine()
- end
- m.write(text)
- end
- function cString(x, y, color, side, text)
- local m = peripheral.wrap(side)
- m.setCursorPos(x,y)
- m.setTextColor(color)
- m.write(text)
- end
- function getTank(tankPeriph)
- local tableInfo = tankPeriph.getTanks("unknown")[1]
- local fluidRaw, fluidName, fluidAmount, fluidCapacity, fluidID
- fluidRaw = tableInfo.rawName
- fluidName = tableInfo.name
- fluidAmount = tableInfo.amount
- fluidCapacity = tableInfo.capacity
- fluidID = tableInfo.id
- return fluidRaw, fluidName, fluidAmount, fluidCapacity, fluidID
- end
- function getBuckets(fluidAmount)
- fluidBuckets = fluidAmount / 1000
- return fluidBuckets
- end
- function numOfMachines()
- local machines = peripheral.getNames()
- count = #machines
- table.sort(machines)
- n = 0
- return n, count
- end
- function comma(number)
- if string.len(number) < 6 then
- -- leave as is
- elseif string.len(number) == 6 then
- number = string.gsub(number, "^(-?%d+)(%d%d%d)", '%1,%2')
- elseif string.len(number) >= 7 and string.len(number) <= 9 then
- number = string.gsub(number, "^(-?%d+)(%d%d%d)(%d%d%d)", '%1,%2,%3')
- elseif string.len(number) == 10 then -- need to fix
- number = string.gsub(number, "^(-?%d+)(%d%d%d)(%d%d%d)(%d%d%d)", '%1,%2,%3,%4')
- else
- end
- number = tostring(number)
- return number
- end
- function dot(ammount)
- local ammount = tostring(ammount)
- local result = string.sub(ammount, -3)
- while string.len(ammount) > 3 do
- ammount = string.sub(ammount,1,-4)
- result = string.sub(ammount,-3)..","..result
- end
- return result
- end
- function itemRename(itemName)
- if (string.find(itemName, "ic2.item",1) == 1) then
- itemName = string.sub(itemName, 9)
- itemName = removeDots(itemName)
- if string.find(itemName, "%s") then
- else
- itemName = spaceAtSecondUpper(itemName)
- end
- elseif (string.find(itemName, "ic2.",1) == 1) then
- itemName = string.sub(itemName, 5)
- itemName = removeDots(itemName)
- if string.find(itemName, "%s") then
- else
- itemName = spaceAtSecondUpper(itemName)
- end
- elseif (string.find(itemName, "tile.mfr.",1) == 1) then
- itemName = string.sub(itemName, 10)
- elseif (string.find(itemName, "appeng.materials.",1) == 1)
- or (string.find(itemName, "AppEng.Materials.",1) == 1) then
- itemName = string.sub(itemName, 18)
- itemName = removeDots(itemName)
- itemName = spaceAtSecondUpper(itemName)
- elseif (string.find(itemName, "item.mfr.",1) == 1) then
- itemName = string.sub(itemName, 10)
- itemName = removeDots(itemName)
- elseif (string.find(itemName, "rubberwood.log.name",1) == 1) then
- itemName = removeDots(itemName)
- end
- return itemName
- end
- function removeDots(itemName)
- itemName = string.gsub(itemName, "%.", " ")
- itemName = string.gsub(itemName, "%name", "")
- itemName = string.gsub(itemName, "block", "")
- return itemName
- end
- function spaceAtSecondUpper(itemName)
- itemName = itemName:gsub("(%S)(%u)", "%1 %2")
- itemName = itemName:gsub("^%s*(.-)%s*$", "%1")
- return itemName
- end
Advertisement
Add Comment
Please, Sign In to add comment