Advertisement
omr__

Kekimurus automation

Nov 17th, 2022 (edited)
905
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.11 KB | Gaming | 0 0
  1. --[[**************************************************************************************
  2. **                                                                                      **
  3. **                                 Kekimurus automation v0.1                            **
  4. **                                Automaticaly place cake blocks                        **
  5. **                                                                                      **
  6. **                                                  Author                              **
  7. **                                                  discord:    om_r#3567               **
  8. **                                                  email:      max.kvy@gmail.com       **
  9. **                                                                                      **
  10. **      ---------------------------------------------------------------------------     **
  11. **      If you want to report a bug, suggest any ideas or just to support - use         **
  12. **      credentials above. I appreciate any feedback!                                   **
  13. **      ---------------------------------------------------------------------------     **
  14. **                                                                                      **
  15. **      Download                                                                        **
  16. **          "pastebin get BbZ3BVL4 kekimurus" and "kekimurus" to execute                **
  17. **          or "pastebin get BbZ3BVL4 startup" - to autorun                             **
  18. **                                                                                      **
  19. **      Usage                                                                           **
  20. **          Place storage with cakes above turtle                                       **
  21. **                                                                                      **
  22. **************************************************************************************--]]
  23.  
  24. local settings = {
  25.     refreshDelay    = 5,
  26.     isLogEnabled    = true,
  27.     placeAround     = true,
  28.     placeAmount     = 2
  29. }
  30.  
  31. -- Support methods
  32. local utils = {}
  33.  
  34. utils.log = function (message)
  35.     if settings.isLogEnabled == true then
  36.         print(message)
  37.     end
  38. end
  39.  
  40. -- Main methods
  41. local app = {}
  42.  
  43. app.checkInventory = function ()
  44.     if turtle.getItemDetail(1) == nil then
  45.         local i = 1
  46.         while i <= settings.placeAmount do
  47.             utils.log('Inventory is empty, taking from storage above...')
  48.             turtle.select(i)
  49.             turtle.suckUp(1)
  50.             i = i + 1
  51.         end
  52.  
  53.         turtle.select(1)
  54.     end
  55. end
  56.  
  57. app.placeForward = function ()
  58.     if turtle.detect() == false then
  59.         local i = 1
  60.         while i <= settings.placeAmount do
  61.             utils.log('Placing item down')
  62.             turtle.place()
  63.             i = i + 1
  64.         end
  65.     end
  66.  
  67.     if settings.placeAround == true then
  68.         turtle.turnLeft()
  69.     end
  70. end
  71.  
  72. app.run = function ()    
  73.     while true do
  74.         app.checkInventory()
  75.         app.placeForward()
  76.        
  77.         --os.sleep(settings.refreshDelay)
  78.     end
  79. end
  80.  
  81. app.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement