Advertisement
Guest User

Collect.lua

a guest
Dec 11th, 2022
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.80 KB | None | 0 0
  1. mats= {}
  2. counts= {}
  3. list= {mats, counts}
  4.  
  5. print(" ")
  6.  
  7. function scanDown(n)
  8.     print("hey I'm starting")
  9.     x, y= turtle.inspectDown()
  10.     material= y.name
  11.     for i=1, #(n[1]) do
  12.         if n[1][i] == material then
  13.             n[2][i]= n[2][i]+1
  14.             print("old material")
  15.             return n
  16.         end
  17.     end
  18.     tempEnd= #(n[1])+1
  19.     n[1][tempEnd]= material
  20.     n[2][tempEnd]= 1
  21.     print("new material")
  22.     return n
  23. end
  24.  
  25. function display(n)
  26.     print(" ")
  27.     for i=1, #(n[1]) do
  28.         print(n[1][i] .. "  ".. n[2][i])
  29.     end
  30. end    
  31.  
  32.  
  33. function save(n, name)
  34.     file= io.open(name, "w")
  35.     for i=1, #(n[1]) do
  36.         file:write(n[1][i].. " ".. n[2][i].. "\n")
  37.     end
  38.     file:close()
  39. end
  40.  
  41. for x=1, 7 do
  42.    list= scanDown(list)
  43.     turtle.forward()
  44. end
  45.  
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement