ecco7777

CC Bee Gene Sample Scanner

May 31st, 2018
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.32 KB | None | 0 0
  1. a=peripheral.wrap("front")
  2. me=peripheral.wrap("bottom")
  3.  
  4. bees=a.getBeeBreedingData()
  5. allSpecies={}
  6. allSpString=""
  7. function addSp(str)
  8. if string.find(allSpString,str)==nil then
  9. allSpString=allSpString..str
  10. allSpecies[#allSpecies+1]=str
  11. end
  12. end
  13.  
  14. for i=1, #bees do
  15. addSp(bees[i].allele1)
  16. addSp(bees[i].allele2)
  17. addSp(bees[i].result)
  18. end
  19.  
  20. function addNBT(var,nbt)
  21. fp=fs.open("species","a")
  22. fp.writeLine("geneByNbt['"..nbt.."']="..var)
  23. fp.close()
  24. end
  25.  
  26. geneByNbt={}
  27. shell.run("species")
  28. items=me.getAvailableItems()
  29.  
  30. for i=1, #items do
  31.     if geneByNbt[items[i].fingerprint]==nil then
  32.         me.exportItem(items[i].fingerprint,"up")
  33.         key=0
  34.         spec=""
  35.         while key~=28 do
  36.             event, key = os.pullEvent("key")
  37.                 if key~=28 and key~=14 and key>11 then
  38.                     spec=spec..keys.getName(key)
  39.                 end
  40.             term.clear()
  41.             term.setCursorPos(1,1)
  42.             term.write(spec)
  43.             option={}
  44.             for i2=1, #allSpecies do
  45.                 if string.find(allSpecies[i2])~=nil then
  46.                     option[#option+1]=allSpecies[i2]
  47.                 end
  48.             end
  49.             for i2=1, #options do
  50.                 term.setCursorPos(1,i2+2)
  51.                 term.write(i2.." "..options[i2])
  52.             end
  53.                 if key>1 and key<11 then
  54.                     spec=option[key-1]
  55.                 end
  56.                 if key==14 then
  57.                     spec=string.sub(spec,1,#spec-1)
  58.                 end
  59.            
  60.         end
  61.         addNBT(spec,items[i].fingerprint.nbt_hash)
  62.         me.pullItem("up")
  63.     end
  64. end
Add Comment
Please, Sign In to add comment