Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Beta
- function name_mod (str)
- j = string.find(str, ":")
- return string.sub(str, 1, j - 1)
- end
- function name_bloc (str)
- j = string.find(str, ":")
- return string.sub(str, j + 1, string.len(str))
- end
- -- Fill hole of the optimine
- function cln_mine()
- for i=1 , 16 do
- local data = turtle.getItemDetail(i)
- if turtle.getItemDetail(i) ~= nil then
- if ((data.name == "minecraft:cobblestone") or (data.name == "minecraft:dirt")) then
- turtle.select(i)
- turtle.placeDown()
- return
- end
- end
- end
- turtle.select(1)
- end
- -- Eject unwanted blocks (arguments: put true if optimine, else put false)
- function clean(opti)
- for i=1 , 16 do
- local data = turtle.getItemDetail(i)
- if turtle.getItemDetail(i) ~= nil then
- if ((data.name == "minecraft:cobblestone") or (data.name == "minecraft:dirt")) and opti then
- turtle.select(i)
- turtle.dropDown(data.count - 1)
- opti = false
- elseif ((data.name == "minecraft:cobblestone") or (data.name == "minecraft:dirt")
- or (name_mod(data.name) == "chisel") or ((name_mod(data.name) ~= arg[1])
- and (name_mod(data.name) ~= arg[2]) and (name_mod(data.name) ~= arg[3]))) then
- turtle.select(i)
- turtle.dropDown(data.count)
- end
- end
- end
- turtle.select(1)
- end
- -- Print items in all slots
- function print_inv()
- for i=1 , 16 do
- local data = turtle.getItemDetail(i)
- turtle.select(i)
- if turtle.getItemDetail(i) ~= nil then
- write("Slot " .. i ..": ".. data.count .. " " .. data.name .. "\n")
- else
- write("Slot " .. i ..": empty \n")
- end
- end
- turtle.select(1)
- end
- -- functions for optimine and sugar canne farming (don't try to understand, except if you want cry)
- function ft_impr ()
- ft_fwd(1)
- turtle.turnRight()
- ft_fwd(2)
- end
- function ft_pair ()
- ft_fwd(2)
- turtle.turnLeft()
- ft_fwd(1)
- end
- -- mine to bedrock
- function mine()
- local success, data = turtle.inspectDown()
- if (data.name == "minecraft:cobblestone") then
- return;
- elseif (data.name ~= "minecraft:bedrock") then
- turtle.digDown()
- for i=1, 4
- do
- turtle.turnRight()
- local success, data = turtle.inspect()
- if success then
- if ((data.name ~= "minecraft:stone") and (data.name ~= "minecraft:grass")
- and (data.name ~= "minecraft:cobblestone")
- and (data.name ~= "minecraft:dirt") and (data.name ~= "TConstruct:GravelOre")
- and (data.name ~= "minecraft:sand") and ((name_mod(data.name) == arg[1])
- or (name_mod(data.name) == arg[2]) or (name_mod(data.name) == arg[3])))
- then
- turtle.dig()
- print("Found : " .. name_bloc(data.name))
- end
- end
- end
- turtle.down()
- mine()
- turtle.up()
- end
- end
- -- optimised minning
- function optimine()
- turtle.select(1)
- print ("Attention !!! Ne prend pas en compte le surplus !!!")
- print ("Please define X")
- xmax = tonumber(read())
- print ("Please define Y")
- ymax = tonumber(read())
- print ("Press F3 and write the value of Y")
- height = tonumber(read())
- fuel = turtle.getFuelLevel()
- fneed = 3 * height * xmax * ymax
- print ("Estimated fuel required : " ..fneed)
- os.sleep(2)
- while fuel < fneed do
- turtle.select(2)
- print ("Put Fuel in slot 2\nStill Requiring : " ..(fneed - fuel))
- os.sleep(3)
- turtle.refuel()
- fuel = turtle.getFuelLevel()
- end
- turtle.select(1)
- x = 1
- y = 1
- while ((x <= xmax) and (y <= ymax)) do
- mine()
- turtle.select(1)
- clean(true)
- cln_mine()
- compact()
- if (x == xmax) and (y == ymax) then break end
- if ((x == xmax) and (y%2 == 0)) then
- if xmax%2 == 1 then turtle.turnRight() end
- ft_impr()
- x = 1
- y = y + 1
- elseif ((x == xmax) and (y%2 == 1)) then
- if xmax%2 == 0 then turtle.turnLeft() end
- ft_pair()
- turtle.turnLeft()
- x = 1
- y = y + 1
- elseif x%2 == 1 then
- ft_impr()
- x = x + 1
- elseif x%2 == 0 then
- ft_pair()
- x = x + 1
- else print("EXTERMINATE !!!")
- end
- end
- end
- -- Final version
- -- move forward (forced), break the blocks forward if there is one
- function ft_fwd(nb)
- i = 0
- while i<nb do
- local success, data = turtle.inspect()
- if success then
- turtle.dig()
- turtle.forward()
- else
- turtle.forward()
- end
- i = i+1
- end
- end
- -- try to stack current slot with next slots
- function stack()
- local slot = turtle.getSelectedSlot()
- if turtle.getItemCount(slot) ~= 0 then
- for i = slot + 1, 16 do
- write (slot .. " ")
- turtle.select(i)
- if turtle.compareTo(slot) then
- turtle.transferTo(slot)
- end
- if turtle.getItemCount(slot) == 64 then
- return
- end
- end
- end
- turtle.select(slot)
- end
- -- try to compact inventory
- function compact ()
- for slot = 1 , 16 do
- write (slot .. " ")
- if turtle.getItemCount(slot) == 0 then
- for i = slot + 1, 16 do
- turtle.select(i)
- if turtle.getItemCount(i) ~= 0 then
- turtle.transferTo(slot)
- break
- end
- if i == 16 then
- turtle.select(1)
- return
- end
- end
- turtle.select(slot)
- end
- end
- turtle.select(1)
- end
- -- stack all slots (require stack)
- function stack_all()
- for i = 1, 16 do
- turtle.select(i)
- stack()
- turtle.select(1)
- end
- end
- function help ()
- print ("Usage of mine :")
- print ("\t mine <name mod 1> <name mod 2> ...")
- print ("Limited to 3 mods")
- print ("If you need more help type: mine more")
- print ("it's case sensitive so check: mine list")
- end
- function more ()
- print ("Example of usage : mine minecraft")
- print ("it will mine all minecraft blocs founds")
- print ("An other example : mine minecraft BigReactors")
- print ("it will mine all minecraft and BigReactors blocs founds")
- end
- function list ()
- print("mods commands:\n")
- print("Tinkers' Construct: TConstruct")
- print("Pam's Haverstcraft : harvestcraft")
- print("Thermal Foundation: ThermalFoundation")
- print("Thaumcraft: Thaumcraft")
- print("Chisel 2: chisel")
- end
- arg = {...}
- local i = #arg
- while i < 3 do
- arg[i + 1] = "none"
- i = i + 1
- end
- if arg [1] == "none" then help()
- elseif arg[1] == "more" then
- more()
- elseif arg[1] == "list" then
- list()
- else optimine()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement