RandomShovel

[1.6] [AE] Item ID Tracker v1.2

Feb 22nd, 2014
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.18 KB | None | 0 0
  1. --[[ Config ]]--
  2.  
  3. manual_update = true
  4. --[[
  5. This will allow you to input a command to update the counter.
  6. $$update is the command to update the counter.
  7. The counter will update every 3 minutes if this is false.
  8. ]]--
  9.  
  10.  
  11. --[[
  12. Do not edit anything below UNLESS you know what you are doing.
  13. You have been warned!
  14. ]]--
  15.  
  16.  
  17. --[[ Tables ]]--
  18.  
  19. local tArgs = { ... }
  20.  
  21.  
  22. --[[ Usage Checker ]]--
  23.  
  24. if #tArgs < 3 then
  25.  printError(shell.getRunningProgram().." <Item ID> <Meta-data> <Item Name>")
  26.  printError("Ensure the item name is SINGULAR!")
  27.  printError("The item name CAN be more than 1 word.")
  28.  printError("Ex: <Program name> 264 0 My diamonds")
  29.  error("Usage error!")
  30. elseif #tArgs > 3 then
  31.  print("It appears you may have a name with spaces.")
  32.  print("Please type the item's name")
  33.  printError("Ensure the item is written singular!")
  34.  print("")
  35.  write("> ")
  36.  name = read()
  37.  name = name.."(s)"
  38.  term.clear()
  39.  term.setCursorPos(1, 1)
  40.  print("Name saved!")
  41.  sleep(1)
  42.  term.clear()
  43.  term.setCursorPos(1, 1)
  44. elseif tArgs[3] ~= nil then
  45.  name = tArgs[3].."(s)"
  46. end
  47.  
  48.  
  49. --[[ Variables ]]--
  50.  
  51. local network = nil
  52. local bridge = nil
  53.  
  54.  
  55. --[[ Functions ]]--
  56.  
  57. function cs()
  58.  --[[ Clears screen ]]--
  59.  term.clear()
  60.  term.setCursorPos(1, 1)
  61. end
  62.  
  63. function bar(title)
  64.  cs()
  65.  textutils.slowPrint(title)
  66.  write("[")
  67.  termX, termY = term.getSize()
  68.  currX, currY = term.getCursorPos()
  69.  term.setCursorPos(termX, currY)
  70.  write("]")
  71.  term.setCursorPos(2, currY)
  72.  for i=1, termX-2 do
  73.   write("+")
  74.   sleep(math.random(0.1, 0.3))
  75.  end
  76. end
  77.  
  78. function findVars()
  79.  sides = peripheral.getNames()
  80.  bar("Finding variables...")
  81.  for i=1, #sides do
  82.   pside = peripheral.getType(sides[i])
  83.   if string.find(pside, "controller") then
  84.    network = peripheral.wrap(sides[i])
  85.   elseif string.find(pside, "glassesbridge") then
  86.    bridge = peripheral.wrap(sides[i])
  87.   end
  88.   cs()
  89.   print("Variables located!")
  90.  end
  91. end
  92.  
  93.  
  94. --[[ Config Reminder ]]--
  95.  
  96. cs()
  97. print("RandomShovel has a message for you!")
  98. print("This program has come with a config!")
  99. print("Use: edit "..shell.getRunningProgram().." to see it!")
  100. sleep(10)
  101.  
  102.  
  103. --[[ Find Variables ]]--
  104.  
  105. findVars()
  106. cs()
  107.  
  108.  
  109. --[[ Boxes and Icons ]]--
  110.  
  111. bridge.clear()
  112.  
  113.  
  114. function backMenu()
  115.  bridge.clear()
  116.  
  117.  statusBackground = bridge.addBox(3, 120, 0, 15, 0x000000, 0.5)
  118.  statusBackground.setZ(1)
  119.  statusText = bridge.addText(6, 125, " ", 0xFFFFFF)
  120.  statusText.setZ(2)
  121.  
  122.  background = bridge.addBox(3, 100, 0, 15, 0x000000, 0.5)
  123.  background.setWidth(bridge.getStringWidth(network.countOfItemType(tonumber(tArgs[1]), tonumber(tArgs[2]))..' '..tostring(name))+6)
  124.  backgroundText = bridge.addText(6, 105, network.countOfItemType(tonumber(tArgs[1]), tonumber(tArgs[2]))..' '..tostring(name), 0xFFFFFF)
  125.  backgroundText.setZ(2)
  126.  background.setZ(1)
  127. end
  128.  
  129. function updateCount()
  130.  if manual_update == false then
  131.   local currstatus = "Updating in 3 minutes..."
  132.   statusBackground.setWidth(bridge.getStringWidth(tostring(currstatus))+6)
  133.   statusText.setText(currstatus)
  134.   sleep(60)
  135.   local currstatus = "Updating in 2 minutes..."
  136.   statusBackground.setWidth(bridge.getStringWidth(tostring(currstatus))+6)
  137.   statusText.setText(currstatus)
  138.   sleep(60)
  139.   local currstatus = "Updating in 1 minute..."
  140.   statusBackground.setWidth(bridge.getStringWidth(tostring(currstatus))+6)
  141.   statusText.setText(currstatus)
  142.   sleep(60)
  143.   local currstatus = "Updating..."
  144.   statusBackground.setWidth(bridge.getStringWidth(tostring(currstatus))+6)
  145.   statusText.setText(currstatus)
  146.   statusText.setText(currstatus)
  147.   sleep(1)
  148.   currstatus = "Updated!"
  149.   statusBackground.setWidth(bridge.getStringWidth(tostring(currstatus))+6)
  150.   statusText.setText(currstatus)
  151.  else
  152.   event, command = os.pullEvent(chat_command)
  153.   if command == "Update" or command == "update" then
  154.    local currstatus = "Updating..."
  155.    statusBackground.setWidth(bridge.getStringWidth(tostring(currstatus))+6)
  156.    statusText.setText(currstatus)
  157.    sleep(1)
  158.    local currstatus = "Updated!"
  159.    statusText.setText(currstatus)
  160.    sleep(1)
  161.   end
  162.  end
  163. end
  164.  
  165.  
  166.  
  167.  
  168. --[[ Main ]]--
  169.  
  170. print("Running "..shell.getRunningProgram().."...")
  171. backMenu()
  172.  
  173. while true do
  174.   updateCount()
  175.   backMenu()
  176.   sleep(0.1)
  177. end
Advertisement
Add Comment
Please, Sign In to add comment