Advertisement
Guest User

MHS

a guest
Oct 31st, 2014
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.68 KB | None | 0 0
  1. --MHS by mh
  2.  
  3. --Advanced Print
  4. _stat = 0
  5. function advPrint(x)
  6.   spacer = string.rep(" ",_stat * 2)
  7.   if type(x) == "table" then
  8.     print(spacer .. "{")
  9.     _stat = _stat + 1
  10.     spacer = string.rep(" ",_stat * 2)
  11.     for k, v in pairs(x) do
  12.       if type(v) == "table" then
  13.         print(spacer .. k..": ")
  14.         advPrint(v)
  15.       else
  16.         print(spacer .. k..": "..tostring(v))
  17.       end
  18.     end
  19.     _stat = _stat - 1
  20.     spacer = string.rep(" ",_stat * 2)
  21.     print(spacer .. "}")
  22.   else
  23.   spacer = string.rep(" ",_stat * 2)
  24.     print(spacer .. tostring(x))
  25.   end
  26. end
  27.  
  28. --STR
  29. sc = {}
  30. sc["a'"] = á
  31. sc["o'"] = ó
  32. sc["o''"] = ő
  33. sc["e'"] = é
  34. sc["u'"] = ú
  35. sc["o.."] = ö
  36. sc["u.."] = ü
  37. sc["u''"] = ű
  38. sc["i'"] = í
  39.  
  40. function str(x)
  41.     x = tostring(x)
  42.     for k, v in pairs(sc) do
  43.         string.gsub(x, k, v)
  44.     end
  45.     return(x)
  46. end
  47.  
  48. --Print Colorlist
  49. function colorList(x)
  50.   print([[white - 1
  51. orange - 2
  52. magenta - 4
  53. lightBlue - 8
  54. yellow - 16
  55. lime - 32
  56. pink - 64
  57. gray - 128
  58. lightGray - 256
  59. cyan - 512
  60. purple - 1024
  61. blue - 2048
  62. brown - 4096
  63. green - 8192
  64. red - 16384
  65. black - 32768]])
  66. end
  67.  
  68. --Color To Number
  69. function colToNum(x)
  70.   y = 0
  71.   if x.white then y = y + 2 ^ 0 end
  72.   if x.orange then y = y + 2 ^ 1 end
  73.   if x.magenta then y = y + 2 ^ 2 end
  74.   if x.lightBlue then y = y + 2 ^ 3 end
  75.   if x.yellow then y = y + 2 ^ 4 end
  76.   if x.lime then y = y + 2 ^ 5 end
  77.   if x.pink then y = y + 2 ^ 6 end
  78.   if x.gray then y = y + 2 ^ 7 end
  79.   if x.lightGray then y = y + 2 ^ 8 end
  80.   if x.cyan then y = y + 2 ^ 9 end
  81.   if x.purple then y = y + 2 ^ 10 end
  82.   if x.blue then y = y + 2 ^ 11 end
  83.   if x.brown then y = y + 2 ^ 12 end
  84.   if x.green then y = y + 2 ^ 13 end
  85.   if x.red then y = y + 2 ^ 14 end
  86.   if x.black then y = y + 2 ^ 15 end
  87.   return y
  88. end
  89.  
  90. -- Number To Color
  91. function numToCol(x)
  92.   y = {}
  93.   y.white = false
  94.   y.orange = false
  95.   y.magenta = false
  96.   y.lightBlue = false
  97.   y.yellow = false
  98.   y.lime = false
  99.   y.pink = false
  100.   y.gray = false
  101.   y.lightGray = false
  102.   y.cyan = false
  103.   y.purple = false
  104.   y.blue = false
  105.   y.brown = false
  106.   y.green = false
  107.   y.red = false
  108.   y.black = false
  109.   while true do
  110.     if x >= 2 ^ 15 then
  111.       x = x - 2 ^ 15
  112.       y.black = true
  113.     elseif x >= 2 ^ 14 then
  114.       x = x - 2 ^ 14
  115.       y.red = true
  116.     elseif x >= 2 ^ 13 then
  117.       x = x - 2 ^ 13
  118.       y.green = true
  119.     elseif x >= 2 ^ 12 then
  120.       x = x - 2 ^ 12
  121.       y.brown = true
  122.     elseif x >= 2 ^ 11 then
  123.       x = x - 2 ^ 11
  124.       y.blue = true
  125.     elseif x >= 2 ^ 10 then
  126.       x = x - 2 ^ 10
  127.       y.purple = true
  128.     elseif x >= 2 ^ 9 then
  129.       x = x - 2 ^ 9
  130.       y.cyan = true
  131.     elseif x >= 2 ^ 8 then
  132.       x = x - 2 ^ 8
  133.       y.lightGray = true
  134.     elseif x >= 2 ^ 7 then
  135.       x = x - 2 ^ 7
  136.       y.gray = true
  137.     elseif x >= 2 ^ 6 then
  138.       x = x - 2 ^ 6
  139.       y.pink = true
  140.     elseif x >= 2 ^ 5 then
  141.       x = x - 2 ^ 5
  142.       y.lime = true
  143.     elseif x >= 2 ^ 4 then
  144.       x = x - 2 ^ 4
  145.       y.yellow = true
  146.     elseif x >= 2 ^ 3 then
  147.       x = x - 2 ^ 3
  148.       y.lightBlue = true
  149.     elseif x >= 2 ^ 2 then
  150.       x = x - 2 ^ 2
  151.       y.magenta = true
  152.     elseif x >= 2 ^ 1 then
  153.       x = x - 2 ^ 1
  154.       y.orange = true
  155.     elseif x >= 2 ^ 0 then
  156.       x = x - 2 ^ 0
  157.       y.white = true
  158.     elseif x == 0 then
  159.       break
  160.     end
  161.   end
  162.   return y
  163. end
  164.  
  165. --Set Single Color
  166. function setBundledColor(side, color, status)
  167.   tableOfColors = numToCol(rs.getBundledOutput(side))
  168.   tableOfColors[color] = status
  169.   rs.setBundledOutput(side,colToNum(tableOfColors))
  170. end
  171.  
  172. --Get Single Color
  173. function getBundledColor(side, color)
  174.   tableOfColors = numToCol(rs.getBundledInput(side))
  175.   return tableOfColors[color]
  176. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement