Advertisement
Guest User

CC_fish1_2017-03-29

a guest
Mar 29th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. --##################
  2. -- Fishing program.
  3. -- Author: smk7758
  4. --##################
  5.  
  6. TIME_INTERVAL = 35
  7. LONG_TO_CHEST = 3
  8. CHEST_HIGHT = 2
  9.  
  10. --##################
  11.  
  12. function putChest()
  13. CHEST_PLACE = 1
  14. for i=1, LONG_TO_CHEST do
  15. turtle.forward()
  16. end
  17. for i=1, 16 do
  18. ITEM_COUNT = turtle.getItemCount(i)
  19. isPUT_CHEST = turtle.itemDrop(ITEM_COUNT)
  20. if not isPUT_CHEST then
  21. -- If: Can't put in chest.
  22. if CHEST_PLACE <= CHEST_HIGHT then
  23. turtle.up()
  24. CHEST_PLACE = CHEST_PLACE + 1
  25. else
  26. print("Chest: Error")
  27. print("Can't find a empty chests. Please make empty chest.")
  28. print("The program will stop after return home.")
  29. end
  30. end
  31. if CHEST_PLACE ~= 1 then
  32. -- If: CHEST_PLACE is not fist number.
  33. for i=1, CHEST_PLACE do
  34. turtle.down()
  35. end
  36. end
  37. for i=1, LONG_TO_CHEST do
  38. turtle.back()
  39. end
  40. if CHEST_PLACE <= CHEST_HIGHT then
  41. os.restart()
  42. else
  43. print("Put all items to chest.")
  44. end
  45. end
  46.  
  47. function isItemFull()
  48. isFULL = {}
  49. for i=1, 16 do
  50. if turtle.getItemSpace(i) == 0 then
  51. isFULL[i] = true
  52. else
  53. isFULL[i] = false
  54. end
  55. end
  56. if isFULL[1] and isFULL[2] and isFULL[3] and isFULL[4] and isFULL[5] and isFULL[6] and isFULL[7] and isFULL[8] and isFULL[9] and isFULL[10] and isFULL[11] and isFULL[12] and isFULL[13] and isFULL[14] and isFULL[15] and isFULL[16] then
  57. -- If: All isFULL are full.
  58. return 1
  59. else
  60. return 0
  61. end
  62. end
  63.  
  64. --##################
  65. -- Main
  66.  
  67. print("If you want to stop this program, press \"Ctrl+T\" for a while time.")
  68. while true do
  69. isDOWN_WATER = turtle.attackDown()
  70. if not isDOWN_WATER then
  71. print("There is no water down turtle.")
  72. print("Press any key to stop this program.")
  73. os.pullEvent("key")
  74. print("Reboot.")
  75. os.reboot()
  76. end
  77. print("Start fishing.")
  78. sleep(TIME_INTERVAL)
  79. isFISH = turtle.digDown()
  80. -- not use: isFISH
  81. print("Fish something.")
  82. print("Start checking item slots.")
  83. if isItemFull() == 0 then
  84. print("Slot: Error")
  85. print("The all item slots are full. Turtle is going to put items in chest.")
  86. putChest()
  87. else
  88. print("Slot: OK")
  89. end
  90. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement