Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- hello!
- -- 15 szeles
- -- 4 magas
- -- ez mar epit is, nem csak as
- -- kezdes: baloldalt legszelen
- -- nem a dirt szinten, hanem felette
- -- asas iranyaba nezve
- -- arg: len
- tArgs = { ... }
- if (#tArgs ~= 1) then
- print("Usage: farminer [length]")
- return
- end
- print("Running xXx EpiC F4rmIn3r xXx 18000!!!")
- target_length = tArgs[1]
- target_floor = "minecraft:dirt"
- target_wall = "minecraft:cobblestone"
- target_roof = "minecraft:glass"
- function check_refuel()
- if turtle.getFuelLevel() < 10 then
- local stash = turtle.getSelectedSlot()
- select_block("minecraft:coal")
- if not turtle.refuel(1) 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 do_line_down(len,top)
- for i=1,len do
- if i < len then
- if turtle.detect() then
- turtle.dig()
- end
- end
- if top then
- local skip_roof = false
- local is_top,top_data = turtle.inspectUp()
- if is_top then
- if top_data and top_data.name == target_roof then
- skip_roof = true
- else
- turtle.digUp()
- end
- end
- if not skip_roof then
- select_block(target_roof)
- turtle.placeUp()
- end
- else -- top
- -- this is bottom
- local water_hole = ((i == 5) or (i == 11))
- 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 water_hole then
- if (not skip_floor) then
- select_block(target_floor)
- turtle.placeDown()
- end
- else -- put cobblestone
- turtle.digDown()
- turtle.down()
- check_refuel()
- select_block(target_wall)
- turtle.placeDown()
- turtle.up()
- check_refuel()
- end
- end -- not top
- if i < len then
- turtle.forward()
- end
- check_refuel()
- sleep(0.1)
- end
- end
- function do_wall()
- select_block(target_wall)
- turtle.dig()
- turtle.place()
- end
- -- Main
- turtle.turnRight()
- for j=1,target_length do
- do_line_down(15,false) -- bottom
- -- arrived right
- -- wall elemet
- do_wall()
- -- go up
- turtle.digUp()
- turtle.up()
- check_refuel()
- -- another wall element
- do_wall()
- -- move up
- turtle.digUp()
- turtle.up()
- check_refuel()
- -- wall
- do_wall()
- -- turn around
- turtle.turnLeft()
- turtle.turnLeft()
- -- roof
- do_line_down(15,true) -- top
- -- arrived left
- --wall
- do_wall()
- -- go down
- turtle.digDown()
- turtle.down()
- check_refuel()
- -- wall
- do_wall()
- -- down
- turtle.digDown()
- turtle.down()
- check_refuel()
- -- last wall piece
- do_wall()
- -- next layer
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- check_refuel()
- turtle.turnRight()
- end
- turtle.turnLeft()
- print("Done farmining")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement