RandomShovel

[CC][Beta] Item ID Tracker v1.1

Dec 5th, 2013
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.13 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.  cs()
  39.  print("Name saved!")
  40.  sleep(1)
  41.  cs()
  42. elseif tArgs[3] ~= nil then
  43.  name = tArgs[3].."(s)"
  44. end
  45.  
  46.  
  47. --[[ Variables ]]--
  48.  
  49. local network = nil
  50. local bridge = nil
  51.  
  52.  
  53. --[[ Functions ]]--
  54.  
  55. function cs()
  56.  --[[ Clears screen ]]--
  57.  term.clear()
  58.  term.setCursorPos(1, 1)
  59. end
  60.  
  61. function bar(title)
  62.  cs()
  63.  textutils.slowPrint(title)
  64.  write("[")
  65.  termX, termY = term.getSize()
  66.  currX, currY = term.getCursorPos()
  67.  term.setCursorPos(termX, currY)
  68.  write("]")
  69.  term.setCursorPos(2, currY)
  70.  for i=1, termX-2 do
  71.   write("+")
  72.   sleep(math.random(0.1, 0.3))
  73.  end
  74. end
  75.  
  76. function findVars()
  77.  sides = peripheral.getNames()
  78.  bar("Finding variables...")
  79.  for i=1, #sides do
  80.   pside = peripheral.getType(sides[i])
  81.   if string.find(pside, "controller") then
  82.    network = peripheral.wrap(sides[i])
  83.   elseif string.find(pside, "glassesbridge") then
  84.    bridge = peripheral.wrap(sides[i])
  85.   end
  86.   cs()
  87.   print("Variables located!")
  88.  end
  89. end
  90.  
  91.  
  92. --[[ Config Reminder ]]--
  93.  
  94. cs()
  95. print("RandomShovel has a message for you!")
  96. print("This program has come with a config!")
  97. print("Use: edit "..shell.getRunningProgram().." to see it!")
  98. sleep(10)
  99.  
  100.  
  101. --[[ Find Variables ]]--
  102.  
  103. findVars()
  104. cs()
  105.  
  106.  
  107. --[[ Boxes and Icons ]]--
  108.  
  109. bridge.clear()
  110.  
  111.  
  112. function backMenu()
  113.  bridge.clear()
  114.  
  115.  statusBackground = bridge.addBox(3, 120, 0, 15, 0x000000, 0.5)
  116.  statusBackground.setZIndex(1)
  117.  statusText = bridge.addText(6, 125, " ", 0xFFFFFF)
  118.  statusText.setZIndex(2)
  119.  
  120.  background = bridge.addBox(3, 100, 0, 15, 0x000000, 0.5)
  121.  background.setWidth(bridge.getStringWidth(network.countOfItemType(tonumber(tArgs[1]), tonumber(tArgs[2]))..' '..tostring(name))+6)
  122.  backgroundText = bridge.addText(6, 105, network.countOfItemType(tonumber(tArgs[1]), tonumber(tArgs[2]))..' '..tostring(name), 0xFFFFFF)
  123.  backgroundText.setZIndex(2)
  124.  background.setZIndex(1)
  125. end
  126.  
  127. function updateCount()
  128.  if manual_update == false then
  129.   local currstatus = "Updating in 3 minutes..."
  130.   statusBackground.setWidth(bridge.getStringWidth(tostring(currstatus))+6)
  131.   statusText.setText(currstatus)
  132.   sleep(60)
  133.   local currstatus = "Updating in 2 minutes..."
  134.   statusBackground.setWidth(bridge.getStringWidth(tostring(currstatus))+6)
  135.   statusText.setText(currstatus)
  136.   sleep(60)
  137.   local currstatus = "Updating in 1 minute..."
  138.   statusBackground.setWidth(bridge.getStringWidth(tostring(currstatus))+6)
  139.   statusText.setText(currstatus)
  140.   sleep(60)
  141.   local currstatus = "Updating..."
  142.   statusBackground.setWidth(bridge.getStringWidth(tostring(currstatus))+6)
  143.   statusText.setText(currstatus)
  144.   statusText.setText(currstatus)
  145.   sleep(1)
  146.   currstatus = "Updated!"
  147.   statusBackground.setWidth(bridge.getStringWidth(tostring(currstatus))+6)
  148.   statusText.setText(currstatus)
  149.  else
  150.   event, command = os.pullEvent(chat_command)
  151.   if command == "Update" or command == "update" then
  152.    local currstatus = "Updating..."
  153.    statusBackground.setWidth(bridge.getStringWidth(tostring(currstatus))+6)
  154.    statusText.setText(currstatus)
  155.    sleep(1)
  156.    local currstatus = "Updated!"
  157.    statusText.setText(currstatus)
  158.    sleep(1)
  159.   end
  160.  end
  161. end
  162.  
  163.  
  164.  
  165.  
  166. --[[ Main ]]--
  167.  
  168. print("Running "..shell.getRunningProgram().."...")
  169. backMenu()
  170.  
  171. while true do
  172.   updateCount()
  173.   backMenu()
  174.   sleep(0.1)
  175. end
Advertisement
Add Comment
Please, Sign In to add comment