Advertisement
OldFarmerJoe

Minecraft DW Bee Analyzer v0

Mar 28th, 2013
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.86 KB | None | 0 0
  1. local currslot = 1
  2. local princess = 0
  3. local bestDrone = 0
  4. local data=""
  5. local countBees = 0
  6. local beeTable = {}
  7. local currScore = 0
  8.  
  9. s = peripheral.wrap("right")
  10.  
  11. function regTable()
  12.    beeTable["bees.species.industrious"] = 31
  13.    beeTable["bees.species.imperial"] = 30
  14.    beeTable["bees.species.unweary"] = 21
  15.    beeTable["bees.species.majestic"] = 20
  16.    beeTable["bees.species.diligent"] = 11
  17.    beeTable["bees.species.noble"] = 10
  18.    beeTable["bees.species.cultivated"] = 6
  19.    beeTable["bees.species.common"] = 5
  20.    beeTable["bees.species.forest"] = 1
  21.    beeTable["bees.species.meadows"] = 1
  22. end  
  23.  
  24. function getBees()
  25.    turtle.select(1)
  26.    for i = 1,6 do
  27.      if turtle.suck() then countBees = countBees + 1 end
  28.    end
  29. end
  30.  
  31. function returnBees()
  32.    turtle.turnRight()
  33.    turtle.turnRight()
  34.    turtle.select(princess)
  35.    s.dropSneaky(1,1)
  36.    turtle.select(bestDrone)
  37.    s.dropSneaky(0,1)
  38. end
  39.  
  40. function ditchCombs()  
  41.    turtle.turnLeft()
  42.    m = peripheral.wrap("front")
  43.    for i = 1,8 do
  44.      turtle.suck()
  45.      while (not m.isBee()) and (turtle.getItemCount(i) > 0) do
  46.      turtle.select(i)
  47.      turtle.drop()
  48.      if not m.isBee() then
  49.         print("Gotta ditch the combs!")
  50.         turtle.suck()
  51.         turtle.dropDown()
  52.         turtle.select(countBees)
  53.         turtle.transferTo(i, 1)
  54.         countBees = countBees - 1
  55.      end
  56.    end
  57.    end
  58. end
  59.  
  60. function scanBees()
  61.    turtle.turnLeft()
  62.    for i = 1, countBees do
  63.      turtle.select(i)
  64.      turtle.drop()
  65.    end
  66.    print("Sleeping for a minute while the bee scans")
  67.    sleep(26)
  68. end
  69.  
  70. function determineBest(slot)
  71.    score = beeTable[data["speciesPrimary"]] + beeTable[data["speciesSecondary"]]
  72.    print("Current: "..currScore)
  73.    print("NewScore: "..score)
  74.    if(bestDrone == 0) then
  75.      bestDrone = slot
  76.      currScore = score
  77.    else
  78.      if (score > currScore) then
  79.        bestDrone = slot
  80.        currScore = score
  81.      end
  82.    end  
  83. end
  84.  
  85. function analyzeBees()
  86.   for i = 1, countBees do
  87.     turtle.select(i)
  88.     s.suckSneaky(0,1)
  89.     turtle.turnRight()
  90.     turtle.drop()
  91.     m = peripheral.wrap("front")
  92.     data = m.analyze()
  93.     if (data["type"] == "princess") then
  94.       princess = i
  95.       print("Princess = "..i)
  96.     else
  97.       determineBest(i)
  98.     end
  99.     print(data["speciesPrimary"]..":"..data["speciesSecondary"])
  100.     print("BestDrone = "..bestDrone)
  101.     turtle.suck()
  102.     turtle.turnLeft()
  103.     if i ~= countBees then sleep(26) end
  104.    end
  105. end
  106.  
  107.  
  108. function dropExcess()
  109.   for i = 1, 6 do
  110.     turtle.select(i)
  111.     turtle.dropDown()
  112.    end  
  113. end
  114. ------=============================
  115.  
  116. currslot = 1
  117. princess = 0
  118. bestDrone = 0
  119. data=""
  120. countBees = 0
  121. beeTable = {}
  122. currScore = 0
  123.  
  124. regTable()
  125. getBees()
  126. if (turtle.getItemCount(2) > 0) then
  127.    ditchCombs()
  128.    scanBees()
  129.    analyzeBees()
  130.    returnBees()
  131.    dropExcess()
  132. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement