Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- hello!
- -- 15 szeles
- -- 4 magas
- -- kezdes: baloldalt legszelen
- -- nem a dirt szinten, hanem felette
- -- asas iranyaba nezve
- -- arg: len floor_item lamp_item
- tArgs = { ... }
- if (#tArgs ~= 1) then
- print("Usage: farminer [length]")
- return
- end
- print("Running xXx EpiC F4rmIn3r 9000!!!")
- target_length = tArgs[1]
- target_floor = "minecraft:dirt"
- function check_shit()
- if turtle.getFuelLevel() < 10 then
- local stash = turtle.getSelectedSlot()
- select_block("minecraft:coal")
- if not turtle.refuel() then
- error("failed to refuel")
- else
- print("Refueld")
- end
- turtle.select(stash)
- end
- end
- function select_block(_name)
- for i=1,16 do
- local slot_data = turtle.getItemDetail(i)
- if slot_data then
- if (slot_data.name == _name) then
- turtle.select(i)
- return
- end
- end
- end
- error("out of: " .. _name)
- end
- function lamp_place(pos,depth)
- if math.fmod(depth,4) == 0 then -- negyesevel
- if math.fmod(pos,4) == 0 then
- -- lamp must be placed
- turtle.up()
- turtle.digUp()
- check_shit()
- select_block("minecraft:torch")
- if not turtle.placeUp() then
- error("Failed to lamp")
- end
- turtle.down()
- check_shit()
- end
- end
- end
- function do_line_up(len,depth)
- for i=1,len do
- local digged = false
- if i < len then
- if turtle.detect() then
- turtle.dig()
- digged = true
- end
- end
- if turtle.detectUp() then
- turtle.digUp()
- digged = true
- end
- lamp_place(i,depth) -- check b4
- if i < len then
- turtle.forward()
- end
- check_shit()
- if digged then
- sleep(0.1)
- end
- end
- end
- function do_line_down(len)
- for i=1,len do
- if i < len then
- if turtle.detect() then
- turtle.dig()
- end
- end
- local skip_floor = false
- local is_down,down_data = turtle.inspectDown()
- if is_down then
- if (down_data) and (down_data.name == target_floor) then
- skip_floor = true
- else
- turtle.digDown()
- end
- end
- if (not skip_floor) then
- select_block(target_floor)
- turtle.placeDown()
- end
- if i < len then
- turtle.forward()
- end
- sleep(0.1)
- end
- end
- -- Main
- turtle.turnRight()
- for j=1,target_length do
- do_line_down(15)
- -- arrived right
- turtle.digUp()
- turtle.up()
- check_shit()
- turtle.turnLeft()
- turtle.turnLeft()
- do_line_up(15,j)
- -- arrived left
- turtle.digUp()
- turtle.down()
- check_shit()
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- check_shit()
- turtle.turnRight()
- end
- turtle.turnLeft()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement