Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Redstone Bundled Cable Input Detector

By: a guest on Feb 18th, 2013  |  syntax: Lua  |  size: 1.37 KB  |  views: 191  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. colorList =
  2. {
  3.   ["white"] = colors.white,
  4.   ["orange"] = colors.orange,
  5.   ["magenta"] = colors.magenta,
  6.   ["lightBlue"] = colors.lightBlue,
  7.   ["yellow"] = colors.yellow,
  8.   ["lime"] = colors.lime,
  9.   ["pink"] = colors.pink,
  10.   ["gray"] = colors.gray,
  11.   ["lightGray"] = colors.lightGray,
  12.   ["cyan"] = colors.cyan,
  13.   ["purple"] = colors.purple,
  14.   ["blue"] = colors.blue,
  15.   ["brown"] = colors.brown,
  16.   ["green"] = colors.green,
  17.   ["red"] = colors.red,
  18.   ["black"] = colors.black
  19. }
  20.  
  21. sideList = {
  22.   "top",
  23.   "front",
  24.   "left",
  25.   "right",
  26.   "back",
  27.   "bottom"
  28. }
  29.  
  30. stateList = {}
  31.  
  32. for i = 1, table.getn(sideList) do
  33.   stateList[sideList[i]] = {colorList}
  34.   for color,call in pairs(colorList) do
  35.   end
  36. end
  37.  
  38. while true do -- Start an endless loop
  39.   os.pullEvent("redstone") -- Yeild the computer until some redstone changes
  40.     term.clear()
  41.     x = 1
  42.  
  43.   --Check each side & color to see if it's changed.
  44.   for i = 1, table.getn(sideList) do
  45.     for color,call in pairs(colorList) do
  46.       if stateList[sideList[i]][color] ~= redstone.testBundledInput(sideList[i], call) then
  47.         term.setCursorPos(1,x)
  48.         term.write(sideList[i] .. " " .. color .. " is now ")
  49.         term.write(redstone.testBundledInput(sideList[i], call))
  50.         stateList[sideList[i]][color] = redstone.testBundledInput(sideList[i], call)
  51.         x = x + 1
  52.       end
  53.     end
  54.   end
  55. end