Advertisement
Guest User

Debug script for scriptable drones

a guest
Sep 21st, 2017
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.00 KB | None | 0 0
  1. -- Get marker positions
  2. -- M1: Top left corner of mining area
  3. m1 = bot:get_marker_pos("m1")
  4. -- M2: Top right corner
  5. m2 = bot:get_marker_pos("m2")
  6. -- CM: A marker placed to the left of a wooden chest
  7. cm = bot:get_marker_pos("cm")
  8.  
  9. --Function is run for each tile
  10. function loop()
  11.     --Debug printing
  12.     bot:print("Loop")
  13.     bot:print(bot:get_stack())
  14.     --If stack is full
  15.     if bot:get_stack().count == 50 then
  16.         --Move to chest marker
  17.         bot:move_to_marker("cm", function()
  18.             --Move 1 right
  19.             bot:move_offset(1,0,function()
  20.                 --Insert to chest
  21.                 bot:container_insert("wooden-chest", 50)
  22.                 --Move back to m1 and restart the loop
  23.                 bot:move_to_marker("m1",function()
  24.                     loop()
  25.                 end)
  26.             end)
  27.         end)
  28.     else
  29.         --If not full
  30.         --Mine copper
  31.         bot:mine("copper-ore", function(mined)
  32.             --Print mined, and mined status
  33.             bot:print("Mined! " .. tostring(mined))
  34.             --Move 1 right
  35.             bot:move_offset(1, 0, function()
  36.                 --Reset position if out of bounds
  37.                 if bot:get_pos().x < m2.x then
  38.                     --Keep moving
  39.                     loop()
  40.                 elseif bot:get_pos().y > m2.y then
  41.                     --Move back to m1
  42.                     bot:move_to_marker("m1", function()
  43.                         loop()
  44.                     end)
  45.                 else
  46.                     --Move back to m1 x, and down 1 tile
  47.                     local pos = bot:get_pos()
  48.                     bot:print("Moving to start, down 1 line")
  49.                     pos.x = m1.x
  50.                     pos.y = pos.y + 1
  51.                     bot:move(pos, function()
  52.                         loop()
  53.                     end)
  54.                 end
  55.             end)
  56.         end)
  57.     end
  58. end
  59.  
  60. --Start
  61. --Move to m1
  62. bot:move_to_marker("m1", function()
  63.     --Start loop function
  64.     loop()
  65. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement