Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- -- -- -- -- -- -- -- -- --
- -- Project: DKTAPI --
- -- Author: Daniel_Kerman --
- -- Language: Lua / English --
- -- -- -- -- -- -- -- -- -- --
- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
- -- BASIC DECLARATION AND INITIALIZATION --
- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
- oldturtle = turtle;
- counter = {blocksMined=0,counter=0};
- -- -- -- -- -- --
- -- OWN TABLES --
- -- -- -- -- -- --
- gravityBlocks =
- {
- sand="minecraft:sand",
- gravel="minecraft:gravel",
- anvil="minecraft:anvil",
- dragon_egg="minecraft:dragon_egg"
- }
- -- -- -- -- -- -- -- --
- -- BASIC FUNCTIONS --
- -- -- -- -- -- -- -- --
- function forwardBool()
- local success = oldturtle.forward()
- if success == false then
- return forwardBool()
- end
- end
- function backBool()
- local success = oldturtle.back()
- if success == false then
- return backBool()
- end
- end
- function upBool()
- local success = oldturtle.up()
- if success == false then
- return upBool()
- end
- end
- function downBool()
- local success = oldturtle.down()
- if success == false then
- return downBool()
- end
- end
- function gravityBlock()
- local success, data = turtle.inspect()
- if data.name==gravityBlocks.sand or data.name==gravityBlocks.gravel or data.name==gravityBlocks.anvil or data.name==gravityBlocks.dragon_egg then
- return true
- else
- return false
- end
- end
- -- -- -- -- -- -- -- -- -- -- --
- -- TURTLE FUNCTION OVERHAUL --
- -- -- -- -- -- -- -- -- -- -- --
- function forward(n)
- local times = n or 1
- for i=0, times do
- forwardBool()
- end
- end
- function back(n)
- local times = n or 1
- for i=0, times do
- backBool()
- end
- end
- function up(n)
- local times = n or 1
- for i=0, times do
- upBool()
- end
- end
- function down(n)
- local times = n or 1
- for i=0, times do
- downBool()
- end
- end
- function turn(str,n)
- local direction = str or "right"
- local times = n or 1
- if direction == "left" then
- for i=0, times do
- oldturtle.turnLeft()
- end
- else
- for i=0, times do
- oldturtle.turnRight()
- end
- end
- end
- function turnLeft(n)
- local times = n or 1
- for i=0, times do
- oldturtle.turnLeft()
- end
- end
- function turnRight(n)
- local times = n or 1
- for i=0, times do
- oldturtle.turnRight()
- end
- end
- function setSlot(n)
- local slot = n or 1
- oldturtle.select(slot)
- end
- function mainAttack(n)
- local times = n or 1
- for i=0, times do
- oldturtle.attack()
- oldturtle.attackUp()
- oldturtle.attackDown()
- end
- end
- function dig(n)
- local times = n or 1
- for i=0,times do
- if gravityBlock()==false then
- oldturtle.dig()
- addBlocksMined()
- forward()
- else
- oldturtle.dig()
- addBlocksMined()
- sleep(0.4)
- forward()
- end
- end
- end
- function digDown(n)
- local times = n or 1
- for i=0,times do
- oldturtle.digDown()
- addBlocksMined()
- down()
- end
- end
- function digUp(n)
- local times = n or 1
- for i=0,times do
- if gravityBlock==false then
- oldturtle.digUp()
- addBlocksMined()
- up()
- else
- oldturtle.digUp()
- addBlocksMined()
- sleep(1)
- up()
- end
- end
- end
- function quarry(n1,n2,n3)
- local quarryWidth = n1 or 1
- local quarryHeight = n2 or 2
- local times = n3 or 1
- for i=0, times do
- dig()
- digDown(quarryHeight-1)
- turn()
- up(quarryHeight)
- for i=0, quarryWidth-1 do
- dig()
- digDown(quarryHeight-1)
- up(quarryHeight-1)
- end
- end
- end
- -- -- -- -- -- -- -- --
- -- Setter & Getter --
- -- -- -- -- -- -- -- --
- -- Specific Counter --
- function resetCounter(str)
- local str = str or counter
- counter.str = 0
- end
- -- BlocksMined --
- function resetBlocksMined()
- counter.blocksMined = 0
- end
- function setBlocksMined(n)
- local value = n or 0
- counter.blocksMined = value
- end
- function getBlocksMined()
- return counter.blocksMined
- end
- function addBlocksMined(n) -- Works as subtractBlocksMined with negative Numbers
- local value = n or 1
- counter.blocksMined = counter.blocksMined + value
- end
- function subtractBlocksMined(n) -- Works as subtractBlocksMined with negative Numbers
- local value = n or 1
- counter.blocksMined = counter.blocksMined - value
- end
- -- ExCounter --
- function resetExCounter()
- counter.counter = 0
- end
- function setExCounter(n)
- local value = n or 0
- counter.counter = value
- end
- function getExCounter()
- return counter.counter
- end
- function addExCounter(n)
- local value = n or 1
- counter.counter = counter.counter + value
- end
- function subtractExCounter(n)
- local value = n or 1
- counter.counter = counter.counter - value
- end
Advertisement
Add Comment
Please, Sign In to add comment