Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = { ... }
- local side = 40;
- if #tArgs >= 1 then
- side = tonumber(tArgs[1])
- end
- local api = require("api")
- local ENDERCHEST_SLOT = 1
- -- Blacklist
- local blackIds = { "forbidden_arcanus:stella_arcanum" }
- local function blacklist(data)
- for _, value in ipairs(blackIds) do
- if value == data.name then
- return true
- end
- end
- return false
- end
- print("Mining a square of side " .. side)
- local function safeDig(i)
- local exists, blacklisted = api.checkBlacklist(blacklist, i)
- if blacklisted then return false end
- if not exists then return true end
- if not api.dig(i) then
- api.attack(i)
- end
- return true
- end
- local function freeupSpace()
- local dir = api.DOWN
- local exists = true
- while true do
- local blacklisted
- exists, blacklisted = api.checkBlacklist(blacklist, dir)
- if not exists or not blacklisted then
- break
- end
- if dir == api.DOWN then
- dir = api.FRONT
- elseif dir == api.FRONT then
- dir = api.UP
- elseif dir == api.UP then
- api.turn(api.RIGHT)
- dir = api.DOWN
- end
- end
- if exists then
- api.dig(dir)
- end
- api.place(dir, ENDERCHEST_SLOT)
- api.dropAll(dir)
- api.select(ENDERCHEST_SLOT)
- api.dig(dir)
- end
- local function ensureSpace()
- if api.freeSlots() == 0 then
- freeupSpace()
- end
- end
- local function mine()
- local blocksToUp = -1
- local downBy = 0
- local times = 2 * side - 1;
- for n=1,times do
- print("Segment " .. n)
- local blocks = side - math.floor(n / 2)
- for b=1,blocks do
- print("Block " .. b)
- ensureSpace()
- safeDig(api.UP)
- safeDig(api.DOWN)
- while not api.move(api.FRONT) do
- if not safeDig(api.FRONT) then
- safeDig(api.DOWN)
- if api.move(api.DOWN) then
- downBy = downBy + 1
- blocksToUp = 1
- end
- end
- end
- while blocksToUp <= 0 and downBy > 0 do
- if not safeDig(api.UP) then
- break
- end
- if api.move(api.UP) then
- downBy = downBy - 1
- end
- end
- if blocksToUp > 0 then
- blocksToUp = blocksToUp - 1
- end
- end
- api.turn(api.RIGHT)
- end
- freeupSpace()
- end
- mine()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement