Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
-- things not to veinmine local blacklist = { "minecraft:stone", "minecraft:dirt", "minecraft:diorite", "minecraft:andesite", "minecraft:granite", "minecraft:gravel", "quark:slate", "minecraft:grass", "chisel:limestone2" } -- vars to identify the current pos relative to start point local x = 0 local y = 0 local z = 0 local rotation = 0 -- params local x_size, y_size, depth, increment = ... x_size, y_size, depth, increment = tonumber(x_size), tonumber(y_size) - 1, tonumber(depth), tonumber(increment) --checking ore local function check_ore(direction) if direction == "up" then _, j = turtle.inspectUp() if not _ then return false end for i,v in pairs(blacklist) do if j.name == v then return false end end return true elseif direction == "down" then _, j = turtle.inspectDown() if not _ then return false end for i,v in pairs(blacklist) do if _ and j.name == v then return false end end return true elseif direction == "forward" then _, j = turtle.inspect() if not _ then return false end for i,v in pairs(blacklist) do if _ and j.name == v then return false end end return true end end --this is mostly for gravel/confirming if ore local function better_forward() while not turtle.forward() do turtle.dig() turtle.attack() end if check_ore("forward") then return "forward" end if check_ore("up") then return "up" end if check_ore("down") then return "down" end end --veinmine local function veinmine(direction) local rot, positions, tx,ty,tz, turns -- initializing vars and kickstarting based on where ore was found if direction == "forward" then while not turtle.forward() do turtle.dig() turtle.attack() end rot = 0 tx, ty, tz = 0,0,1 positions = {0} turns = {} elseif direction == "up" then while not turtle.up() do turtle.digUp() turtle.attackUp() end rot = 0 tx, ty, tz = 0,1,0 positions = {"down"} turns = {} elseif direction == "down" then while not turtle.down() do turtle.digDown() turtle.attackDown() end rot = 0 tx, ty, tz = 0,-1,0 positions = {"up"} turns = {} end local shortcuts = 0 local skips = 0 local omega_skips = 0 local mined = {} --checks if blocks around turtle are already cleared local function check_around() if mined[tostring(tx - 1) .. tostring(ty) .. tostring(tz)] and mined[tostring(tx + 1) .. tostring(ty) .. tostring(tz)] and mined[tostring(tx) .. tostring(ty) .. tostring(tz - 1)] and mined[tostring(tx) .. tostring(ty) .. tostring(tz + 1)] then return true end return false end local function check_left() --checking if the block to left is checked if rot % 4 == 0 and mined[tostring(tx-1) .. tostring(ty).. tostring(tz)] then return false elseif rot % 4 == 2 and mined[tostring(tx+1) .. tostring(ty).. tostring(tz)] then return false elseif rot % 4 == 1 and mined[tostring(tx) .. tostring(ty).. tostring(tz+1)] then return false elseif rot % 4 == 3 and mined[tostring(tx) .. tostring(ty).. tostring(tz-1)] then return false end --checking if the other blocks around are mined/checked if rot % 4 == 0 and (not mined[tostring(tx) .. tostring(ty).. tostring(tz+1)] or not mined[tostring(tx+1) .. tostring(ty).. tostring(tz)] or mined[tostring(tx) .. tostring(ty).. tostring(tz-1)]) then return false elseif rot % 4 == 2 and (not mined[tostring(tx) .. tostring(ty).. tostring(tz - 1)] or not mined[tostring(tx - 1) .. tostring(ty).. tostring(tz)] or not mined[tostring(tx) .. tostring(ty).. tostring(tz + 1)]) then return false elseif rot % 4 == 1 and (not mined[tostring(tx+1) .. tostring(ty).. tostring(tz)] or not mined[tostring(tx) .. tostring(ty).. tostring(tz - 1)] or not mined[tostring(tx - 1) .. tostring(ty).. tostring(tz)]) then return false elseif rot % 4 == 3 and (not mined[tostring(tx - 1) .. tostring(ty).. tostring(tz)] or not mined[tostring(tx) .. tostring(ty).. tostring(tz + 1)] or not mined[tostring(tx + 1) .. tostring(ty).. tostring(tz)]) then return false end return true end --the veinmine part while #positions ~= 0 do print("Local position:", tx, ty, tz) print("Local rotation:", rot) local found_ore = false if not check_ore("up") then mined[tostring(tx) .. tostring(ty+1) .. tostring(tz)] = true end if not check_ore("down") then mined[tostring(tx) .. tostring(ty - 1) .. tostring(tz)] = true end if check_ore("up") then table.insert(positions, "down") while not turtle.up() do turtle.digUp() turtle.attackUp() end found_ore = true ty = ty + 1 mined[tostring(tx) .. tostring(ty) .. tostring(tz)] = true elseif check_ore("down") then table.insert(positions, "up") while not turtle.down() do turtle.digDown() turtle.attackDown() end found_ore = true ty = ty - 1 mined[tostring(tx) .. tostring(ty) .. tostring(tz)] = true elseif not check_around() then if check_left() then turtle.turnLeft() if check_ore("forward") then table.insert(positions, 3) while not turtle.forward() do turtle.dig() turtle.attack() end if rot % 4 == 1 then tx = tx + 1 elseif rot % 4 == 2 then tz = tz - 1 elseif rot % 4 == 3 then tx = tx - 1 elseif rot % 4 == 0 then tz = tz + 1 end found_ore = true mined[tostring(tx) .. tostring(ty) .. tostring(tz)] = true else local qx, qy, qz = tx, ty, tz if rot % 4 == 1 then qx = qx + 1 elseif rot % 4 == 2 then qz = qz - 1 elseif rot % 4 == 3 then qx = qx - 1 elseif rot % 4 == 0 then qz = qz + 1 end mined[tostring(qx) .. tostring(qy) .. tostring(qz)] = true end else for i = 1,4 do if check_ore("forward") then table.insert(positions, i - 1) turns[tostring(tx) .. tostring(ty) .. tostring(tz)] = i - 1 while not turtle.forward() do turtle.dig() turtle.attack() end if rot % 4 == 1 then tx = tx + 1 elseif rot % 4 == 2 then tz = tz - 1 elseif rot % 4 == 3 then tx = tx - 1 elseif rot % 4 == 0 then tz = tz + 1 end found_ore = true mined[tostring(tx) .. tostring(ty) .. tostring(tz)] = true break else local qx, qy, qz = tx, ty, tz if rot % 4 == 1 then qx = qx + 1 elseif rot % 4 == 2 then qz = qz - 1 elseif rot % 4 == 3 then qx = qx - 1 elseif rot % 4 == 0 then qz = qz + 1 end mined[tostring(qx) .. tostring(qy) .. tostring(qz)] = true end turtle.turnRight() rot = rot + 1 end end end if not found_ore then rot = rot - 4 end if not found_ore then if positions[#positions] == "up" then while not turtle.up() do turtle.digUp() turtle.attackUp() end ty = ty + 1 elseif positions[#positions] == "down" then while not turtle.down() do turtle.digDown() turtle.attackDown() end ty = ty - 1 else if not turtle.back() then turtle.turnRight() turtle.turnRight() while not turtle.forward() do turtle.dig() turtle.attack() end turtle.turnRight() turtle.turnRight() end if positions[#positions] == 3 then turtle.turnRight() rot = rot - 3 else for i = 1, positions[#positions] do turtle.turnLeft() end rot = rot - positions[#positions] end if rot % 4 == 1 then tx = tx - 1 elseif rot % 4 == 2 then tz = tz + 1 elseif rot % 4 == 3 then tx = tx + 1 elseif rot % 4 == 0 then tz = tz - 1 end end table.remove(positions) end end end -- function that returns to start point local function return_to_origin(up) --switch for when something is blocking its way local offset = false -- rotating it to face the starting wall if rotation ~= 2 then if rotation > 2 then repeat turtle.turnLeft() rotation = rotation - 1 until rotation == 2 elseif rotation < 2 then repeat turtle.turnRight() rotation = rotation + 1 until rotation == 2 end end -- moving it out of the way if theres a block in front of it if turtle.detect() and x ~= 0 then offset = true turtle.turnRight() better_forward() turtle.turnLeft() end -- returning to start for i = 1,y do better_forward() end turtle.turnRight() if offset then for i = 1,x-1 do better_forward() end else for i = 1,x do better_forward() end end --rotating back to 0 turtle.turnRight() -- going back to the top if desired if up then for i = 1, z do turtle.up() end end end local function empty_storage(finished) if not finished then for i = 1,16 do if turtle.getItemCount(i) == 0 then return end end end local old_rotation = rotation return_to_origin(true) turtle.turnRight() turtle.turnRight() for i = 1,16 do turtle.select(i) turtle.drop(64) end turtle.turnRight() turtle.turnRight() if not finished then for i = 1, z do turtle.down() end for i = 1, y do better_forward() end turtle.turnRight() for i = 1, x do better_forward() end if old_rotation == 0 then turtle.turnLeft() elseif old_rotation == 2 then turtle.turnRight() end end end local function mine_sector() -- switch to alternate digging left/right local left = false for i = 1, x_size do --digging forward for i = 1, y_size do local result = better_forward() if result then if result == "forward" then veinmine("forward") elseif result == "up" then veinmine("up") elseif result == "down" then veinmine("down") end end if not left then y = y + 1 else y = y - 1 end if y ~= y_size then empty_storage() end end --turning using switch if x ~= x_size - 1 then if not left then turtle.turnRight() local result = better_forward() turtle.turnRight() if result then if result == "forward" then veinmine("forward") elseif result == "up" then veinmine("up") elseif result == "down" then veinmine("down") end end left = true rotation = 2 x = x + 1 else turtle.turnLeft() local result = better_forward() turtle.turnLeft() if result then if result == "forward" then veinmine("forward") elseif result == "up" then veinmine("up") elseif result == "down" then veinmine("down") end end left = false rotation = 0 x = x + 1 end end end end local function dig_deeper() return_to_origin(false) for i = 1, increment do if z == depth then return end z = z + 1 turtle.digDown() turtle.down() end end local function smart_fuel() local fuel_needed = (x_size * y_size) * math.floor(depth / increment) * 1.2 term.clear() if turtle.getFuelLevel() <= fuel_needed then while turtle.getFuelLevel() <= fuel_needed do term.clear() term.setCursorPos(1,1) print("Fuel needed:", fuel_needed) term.setCursorPos(1,2) print("Current fuel:", turtle.getFuelLevel()) turtle.refuel() end end term.clear() print("Success, running quarry.") end local function quarry() smart_fuel() while true do dig_deeper() x,y,rotation = 0,0,0 if z >= depth then break end mine_sector() end if depth % increment == 0 then mine_sector() end empty_storage(true) end quarry()
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
Bitcoin is Amazing
52 sec ago | 0.12 KB
Roblox Scripts
5 hours ago | 0.02 KB
December smells like money
5 hours ago | 0.06 KB
Decentralized Moneys
6 hours ago | 0.42 KB
Bitcoin
6 hours ago | 0.23 KB
Untitled
7 hours ago | 13.75 KB
Untitled
7 hours ago | 0.06 KB
Untitled
11 hours ago | 3.86 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!