Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Get marker positions
- -- M1: Top left corner of mining area
- m1 = bot:get_marker_pos("m1")
- -- M2: Top right corner
- m2 = bot:get_marker_pos("m2")
- -- CM: A marker placed to the left of a wooden chest
- cm = bot:get_marker_pos("cm")
- --Function is run for each tile
- function loop()
- --Debug printing
- bot:print("Loop")
- bot:print(bot:get_stack())
- --If stack is full
- if bot:get_stack().count == 50 then
- --Move to chest marker
- bot:move_to_marker("cm", function()
- --Move 1 right
- bot:move_offset(1,0,function()
- --Insert to chest
- bot:container_insert("wooden-chest", 50)
- --Move back to m1 and restart the loop
- bot:move_to_marker("m1",function()
- loop()
- end)
- end)
- end)
- else
- --If not full
- --Mine copper
- bot:mine("copper-ore", function(mined)
- --Print mined, and mined status
- bot:print("Mined! " .. tostring(mined))
- --Move 1 right
- bot:move_offset(1, 0, function()
- --Reset position if out of bounds
- if bot:get_pos().x < m2.x then
- --Keep moving
- loop()
- elseif bot:get_pos().y > m2.y then
- --Move back to m1
- bot:move_to_marker("m1", function()
- loop()
- end)
- else
- --Move back to m1 x, and down 1 tile
- local pos = bot:get_pos()
- bot:print("Moving to start, down 1 line")
- pos.x = m1.x
- pos.y = pos.y + 1
- bot:move(pos, function()
- loop()
- end)
- end
- end)
- end)
- end
- end
- --Start
- --Move to m1
- bot:move_to_marker("m1", function()
- --Start loop function
- loop()
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement