EnnekPL

enu 1.6.4

Jan 3rd, 2014
977
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.54 KB | None | 0 0
  1. function clearPos(x, y, side)
  2. m = peripheral.wrap(side)
  3. m.setCursorPos(x,y)
  4. m.clearLine()
  5. end
  6.  
  7. function appendString(side, color, text, clear, x, y)
  8. local m = peripheral.wrap(side)
  9. local a,b = m.getCursorPos()
  10.  
  11. if x == 0 and y ~= 0 then
  12. m.setCursorPos(a,y)
  13. elseif x ~= 0 and y == 0 then
  14. -- set x position
  15. m.setCursorPos(x,b)
  16. elseif x ~= 0 and y ~= 0 then
  17. m.setCursorPos(x,y)
  18. elseif x == 0 and y == 0 then
  19. m.setCursorPos(a,b)
  20. end
  21.  
  22. m.setTextColor(color)
  23.  
  24. if clear == true then
  25. m.clearLine()
  26. end
  27.  
  28. m.write(text)
  29. end
  30.  
  31. function cString(x, y, color, side, text)
  32. local m = peripheral.wrap(side)
  33.  
  34. m.setCursorPos(x,y)
  35. m.setTextColor(color)
  36. m.write(text)
  37. end
  38.  
  39. function getTank(tankPeriph)
  40.  
  41. local tableInfo = tankPeriph.getTankInfo("unknown")[1]
  42.  
  43. local fluidRaw, fluidName, fluidAmount, fluidCapacity, fluidID
  44.  
  45. fluidRaw = tableInfo.rawName
  46. fluidName = tableInfo.name
  47. fluidAmount = tableInfo.amount
  48. fluidCapacity = tableInfo.capacity
  49. fluidID = tableInfo.id
  50.  
  51. return fluidRaw, fluidName, fluidAmount, fluidCapacity, fluidID
  52. end
  53.  
  54. function getBuckets(fluidAmount)
  55. fluidBuckets = fluidAmount / 1000
  56.  
  57. return fluidBuckets
  58. end
  59.  
  60. function numOfMachines()
  61.  
  62. local machines = peripheral.getNames()
  63. count = #machines
  64. table.sort(machines)
  65. n = 0
  66.  
  67. return n, count
  68. end
  69.  
  70. function comma(number)
  71. if string.len(number) < 6 then
  72. -- leave as is
  73. elseif string.len(number) == 6 then
  74. number = string.gsub(number, "^(-?%d+)(%d%d%d)", '%1,%2')
  75. elseif string.len(number) >= 7 and string.len(number) <= 9 then
  76. number = string.gsub(number, "^(-?%d+)(%d%d%d)(%d%d%d)", '%1,%2,%3')
  77. elseif string.len(number) == 10 then -- need to fix
  78. number = string.gsub(number, "^(-?%d+)(%d%d%d)(%d%d%d)(%d%d%d)", '%1,%2,%3,%4')
  79. else
  80.  
  81. end
  82. number = tostring(number)
  83. return number
  84. end
  85. function dot(ammount)
  86. local ammount = tostring(ammount)
  87. local result = string.sub(ammount, -3)
  88. while string.len(ammount) > 3 do
  89. ammount = string.sub(ammount,1,-4)
  90. result = string.sub(ammount,-3)..","..result
  91. end
  92. return result
  93. end
  94. function itemRename(itemName)
  95. if (string.find(itemName, "ic2.item",1) == 1) then
  96. itemName = string.sub(itemName, 9)
  97. itemName = removeDots(itemName)
  98.  
  99. if string.find(itemName, "%s") then
  100.  
  101. else
  102.  
  103. itemName = spaceAtSecondUpper(itemName)
  104. end
  105.  
  106. elseif (string.find(itemName, "ic2.",1) == 1) then
  107. itemName = string.sub(itemName, 5)
  108. itemName = removeDots(itemName)
  109.  
  110. if string.find(itemName, "%s") then
  111.  
  112. else
  113. itemName = spaceAtSecondUpper(itemName)
  114. end
  115.  
  116. elseif (string.find(itemName, "tile.mfr.",1) == 1) then
  117. itemName = string.sub(itemName, 10)
  118. elseif (string.find(itemName, "appeng.materials.",1) == 1)
  119. or (string.find(itemName, "AppEng.Materials.",1) == 1) then
  120. itemName = string.sub(itemName, 18)
  121. itemName = removeDots(itemName)
  122. itemName = spaceAtSecondUpper(itemName)
  123. elseif (string.find(itemName, "item.mfr.",1) == 1) then
  124. itemName = string.sub(itemName, 10)
  125. itemName = removeDots(itemName)
  126. elseif (string.find(itemName, "rubberwood.log.name",1) == 1) then
  127. itemName = removeDots(itemName)
  128. end
  129.  
  130.  
  131. return itemName
  132. end
  133.  
  134. function removeDots(itemName)
  135. itemName = string.gsub(itemName, "%.", " ")
  136. itemName = string.gsub(itemName, "%name", "")
  137. itemName = string.gsub(itemName, "block", "")
  138.  
  139. return itemName
  140. end
  141.  
  142. function spaceAtSecondUpper(itemName)
  143. itemName = itemName:gsub("(%S)(%u)", "%1 %2")
  144. itemName = itemName:gsub("^%s*(.-)%s*$", "%1")
  145.  
  146. return itemName
  147. end
Advertisement
Add Comment
Please, Sign In to add comment