Advertisement
Guest User

test

a guest
Jun 25th, 2015
515
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.28 KB | None | 0 0
  1. --      Title: me_exportbus test program
  2. --
  3. --  File Name: test
  4. --
  5. --Description: Reads all items in database and
  6. --             attempts to export 1 instance of
  7. --             each item to a chest through the
  8. --             export bus
  9. --
  10. --      Notes: I use sides.bottom here, this will
  11. --             be different depending on the placement
  12. --             of your me_exportbus! I will eventually
  13. --             write a function to set this value
  14. --             dynamically (or maybe not, I'm lazy)
  15. --
  16. --             Keep in mind the database itemstack info
  17. --             is manually added at the moment, I will
  18. --             eventually add a means of using an inventory
  19. --             controller to manage the database programmatically
  20. --             (if possible with ME system)
  21.  
  22. local component = require('component')
  23. local sides = require('sides')
  24. local db = component.database
  25. local cont = component.me_controller --not actually used
  26. local exBus = component.me_exportbus
  27. local busSide = sides.bottom --you might need to change this
  28.  
  29. --for loop to print all the items in DB
  30. --should dynamically calculate end of loop
  31. for i = 1, 5 do
  32.   item = db.get(i)
  33.   print("--ITEM " .. i ..  " START--")
  34.   for k,v in pairs(item) do
  35.     print(k,v)
  36.   end
  37.   print("--ITEM " .. i .. " END--")
  38. end
  39.  
  40. print("\n\n")
  41.  
  42. --for loop sets the export config to a different item
  43. --each loop, prints the config, then tries to export 1 item.
  44. --Should also dynamically calculated end of loop, but in actual
  45. --real use I probably will have a function along the lines of
  46. --exportItem(itemName) or something similar, which will do all
  47. --the work required to set the export config and pump out a single
  48. --instance of that item to the chest (resetting the config after)
  49. for i = 0, 4 do
  50.  
  51.   --start run i and set config for next item
  52.   print("--------- Run " .. i .. " Start ---------\n")
  53.   print("Set Config: ",exBus.setExportConfiguration(busSide, 1, db.address, i+1))
  54.  
  55.   --print the config, comment this block out if you don't care
  56.   config = exBus.getExportConfiguration(busSide, 1)
  57.   print("\n!! Export Bus Config Start !!\n")
  58.   for k,v in pairs(config) do
  59.     print(k,v)
  60.   end
  61.   print("\n!! Export Bus Config End !!\n")
  62.  
  63.   print("Try Export: ",exBus.exportIntoSlot(busSide,i+1), "\n") -- try export an item
  64.  
  65. end
  66.  
  67. exBus.setExportConfiguration(0) --clear the config
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement