NielsUtrecht

base-ae-dump

Sep 10th, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.60 KB | None | 0 0
  1. if(not os.loadAPI("hydraApi")) then
  2.     error("Could not load hydraApi")
  3. end
  4.  
  5. local bridge = hydraApi.getMeBridge()
  6. local list = bridge.listItems()
  7.  
  8. local handle = fs.open("itemmap.txt", "r")
  9. if(handle == nil) then
  10.     itemMap = {}
  11. else
  12.     itemMap = textutils.unserialize(handle.readAll())
  13.     handle.close()
  14.     if(itemMap == nil) then
  15.         itemMap = {}
  16.     end
  17. end
  18.  
  19. for k,v in pairs(list) do
  20.     if(itemMap[k] == nil) then
  21.         itemMap[k] = v
  22.     end
  23. end
  24.  
  25. local handle = fs.open("itemmap.txt", "w")
  26. local str = textutils.serialize(itemMap)
  27. str = string.gsub(str, ",%[",",\n%[")
  28. handle.write(str)
  29. handle.close()
Add Comment
Please, Sign In to add comment