Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
--Created by makeo. All rights reserved. --DO NOT EDIT local FUEL_SLOT = 1 local CHEST_FUEL_SLOT = 1 local ENDER_CHEST_SLOT = 2 local DIG_SLOT = 3 --save movments function move(move, detect, dig, attack) if needsPitstop() then doPitstop() end local first = true while not move() do if detect() then turtle.select(DIG_SLOT) dig() else attack() end if not first then sleep(0.5) end first = false end end function moveForward() move(turtle.forward, turtle.detect, turtle.dig, turtle.attack) end function moveBack() if not turtle.back() then turn180() moveForward() turn180() end end function moveUp() move(turtle.up, turtle.detectUp, turtle.digUp, turtle.attackUp) end function moveDown() move(turtle.down, turtle.detectDown, turtle.digDown, turtle.attackDown) end function turn180() turtle.turnLeft() turtle.turnLeft() end --pitstop function doPitstop() if turtle.getItemDetail(ENDER_CHEST_SLOT) == nil then if peripheral.getType("bottom") ~= "ender_chest" then error("No ender chest found.") end else if turtle.detectDown() then turtle.select(DIG_SLOT) turtle.digDown() end turtle.select(ENDER_CHEST_SLOT) turtle.placeDown() sleep(0.5) end if (not hasSpace()) or getMovingHome() then for i = 3, 16, 1 do while turtle.getItemCount(i) > 0 do turtle.select(i) turtle.dropDown() sleep(0.5) if not moved then sleep(2) end end end end turtle.select(ENDER_CHEST_SLOT) turtle.digDown() end function needsPitstop() return (not hasSpace()) or turtle.getFuelLevel() < 5 end function hasSpace() local count = 0 for i = 3, 16, 1 do if turtle.getItemCount(i) == 0 then count = count + 1 end end return count > 1 end function readNumber(minVal) local num = -1 repeat if num ~= -1 then print("Text is not a number.") end num = tonumber(read()) if num ~= nil and num < minVal then print("Number is out of bound.") num = nil end until num ~= nil return num end --ore stuff function isOre() local success, data = turtle.inspect() return checkOre(success, data) end function isOreUp() local success, data = turtle.inspectUp() return checkOre(success, data) end function isOreDown() local success, data = turtle.inspectDown() return checkOre(success, data) end function checkOre(success, data) if success then local name = data["name"] if name ~= nil then --Alternative name bypass if name == "Forestry:resources" or name == "TConstruct:SearedBrick" or name == "denseores:block0" or name == "rftools:dimensionalShardBlock" or name == "harvestcraft:salt" then return true end local index = string.find(name, ":") if index ~= nil then local part = string.lower(string.sub(name, index)) local isOre = string.find(part, "ore") return isOre ~= nil end end end return false end --vein stuff function mineVein() while true do if isOre() then veinMoveForward() elseif isOreUp() then veinMoveUp() elseif isOreDown() then veinMoveDown() else local success = false for i = 1, 3, 1 do veinMoveLeft() if isOre() then veinMoveForward() success = true break end end if not success then if not popVeinMovment() then return end end end sleep(0.5) end end function veinMoveForward() moveForward() pushToVeinStack(1) end function veinMoveUp() moveUp() pushToVeinStack(2) end function veinMoveDown() moveDown() pushToVeinStack(3) end function veinMoveLeft() turtle.turnLeft() pushToVeinStack(4) end function veinMoveRight() turtle.turnRight() pushToVeinStack(5) end function veinMoveBack() moveBack() pushToVeinStack(6) end function popVeinMovment() local direction = getFromVeinStack() if direction == nil then return false end if direction == 1 then moveBack() elseif direction == 2 then moveDown() elseif direction == 3 then moveUp() elseif direction == 4 then turtle.turnRight() removeLastVeinStack() return popVeinMovment() elseif direction == 5 then turtle.turnLeft() removeLastVeinStack() return popVeinMovment() elseif direction == 6 then moveForward() end removeLastVeinStack() return true; end function pushToVeinStack(direction) local stack = getVeinStack() if stack == nil then stack = {} end stack[#stack + 1] = direction stack = optimizeVeinStack(stack) saveVeinStack(stack, #stack) end function getFromVeinStack() local data = getVeinStack() if data ~= nil then return data[#data] end return nil end function optimizeVeinStack(data) local lastAction = 0 local actionCount = 0 local i = 1 while i <= #data do --turn right and then left is somewhat useless if (data[i] == 4 and lastAction == 5) or (data[i] == 5 and lastAction == 4) then data = moveArrayContent(data, i + 1, 2) if #data < 1 then break end i = 1 lastAction = 0 actionCount = 0 end if data[i] ~= lastAction then lastAction = 0 actionCount = 0 end if data[i] == 4 then lastAction = 4 actionCount = actionCount + 1 elseif data[i] == 5 then lastAction = 5 actionCount = actionCount + 1 end if actionCount == 3 then local newAction = 4 if lastAction == 4 then newAction = 5 end data = moveArrayContent(data, i + 1, 2) data[i - 2] = newAction i = 0 lastAction = 0 actionCount = 0 end i = i + 1 end return data end function moveArrayContent(array, startIndex, amount) local size = #array for i = startIndex, size + amount, 1 do array[i - amount] = array[i] array[i] = nil end return array end function removeLastVeinStack() local data = getVeinStack() saveVeinStack(data, #data - 1) end function saveVeinStack(data, length) if data ~= nil then local dataLeng = #data for i = length + 1, dataLeng, 1 do data[i] = nil end end if #data < 1 then data = nil end setVeinStack(data) end function getVeinStack() return getVariable("veinStack") end function setVeinStack(value) setVariable("veinStack", value) end function getVariable(name) local vars = getVariables() if vars ~= nil then return vars[name] end return nil end function setVariable(name, value) local vars = getVariables() if vars == nil then vars = {} end vars[name] = value local handle = fs.open("Vars.dat", "w") handle.writeLine(textutils.serialize(vars)) handle.close() end function getVariables() local handle = fs.open("Vars.dat", "r") if handle ~= nil then local raw = handle.readAll() handle.close() if raw ~= nil then return textutils.unserialize(raw) end end return nil end function getStripLength() return getVariable("stripLength") end function setStripLength(value) setVariable("stripLength", value) end function getStripPos() return getVariable("stripPos") end function setStripPos(value) setVariable("stripPos", value) end function getStripOnGround() return getVariable("stripGround") end function setStripOnGround(value) return setVariable("stripGround", value) end function getStripHasDug() return getVariable("stripHasDug") end function setStripHasDug(value) return setVariable("stripHasDug", value) end function getStripHasFinished() return getVariable("stripHasFinished") end function setStripHasFinished(value) return setVariable("stripHasFinished", value) end function digStrip(gotoStart) local length = getStripLength() if not getStripHasFinished() then while getStripPos() <= length or (not getStripHasDug()) do mineVein() if getStripHasDug() then moveForward() setStripPos(getStripPos() + 1) setStripHasDug(false) else if getStripOnGround() then moveUp() setStripOnGround(false) else moveDown() setStripOnGround(true) end setStripHasDug(true) end end setStripHasFinished(true) end mineVein() if not getStripOnGround() then moveDown() setStripOnGround(true) mineVein() end if gotoStart then while getStripPos() > 1 do moveBack() setStripPos(getStripPos() - 1) sleep(0.5) end end end function clearStripParams() setStripLength(0) setStripPos(1) setStripOnGround(true) setStripHasDug(false) setStripHasFinished(false) end function getIsPreparing() return getVariable("isPreparing") end function setIsPreparing(value) return setVariable("isPreparing", value) end function getSpacing() return getVariable("spacing") end function setSpacing(value) return setVariable("spacing", value) end function getDepth() return getVariable("depth") end function setDepth(value) return setVariable("depth", value) end function getStripCount() return getVariable("stripCount") end function setStripCount(value) return setVariable("stripCount", value) end function getRemainingStripCount() return getVariable("remainStripCount") end function setRemainingStripCount(value) return setVariable("remainStripCount", value) end function getMovingHome() return getVariable("movHome") end function setMovingHome(value) return setVariable("movHome", value) end function prepareNextStrip() if not getIsPreparing() then turtle.turnRight() setIsPreparing(true) clearStripParams() end setStripLength(getSpacing() + 1) digStrip(false) clearStripParams() turtle.turnLeft() setIsPreparing(false) setStripHasFinished(false) end function goHome() if not getMovingHome() then turtle.turnLeft() setMovingHome(true) setStripPos(1) end local length = ((getStripCount() - 1) * (getSpacing() + 1)) while getStripPos() <= length do moveForward() setStripPos(getStripPos() + 1) end doPitstop() turtle.turnRight() fs.delete("Vars.dat") print("All strips cleared.") error() end function initVars() clearStripParams() setIsPreparing(false) setMovingHome(false) print("Enter the spacing between the strips.") setSpacing(readNumber(0)) print("Enter the depth of each strip.") setDepth(readNumber(1)) print("Enter the amount of strips.") local stripCount = readNumber(1) setStripCount(stripCount) setRemainingStripCount(stripCount) end if getSpacing() == nil then initVars() end while true do if getMovingHome() then goHome() end if getIsPreparing() then prepareNextStrip() elseif not getStripHasFinished() then setStripLength(getDepth()) digStrip(true) clearStripParams() local remStrips = getRemainingStripCount() - 1 setRemainingStripCount(remStrips) if remStrips < 1 then goHome() end prepareNextStrip() end end
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
I made $15,000 * 2 hours
CSS | 8 min ago | 0.99 KB
✅ API Glitch (Docs Leak)
CSS | 9 min ago | 0.99 KB
Custom Placeholder: Event Image using alt tag...
12 hours ago | 0.50 KB
Untitled
Bash | 22 hours ago | 1.17 KB
Using Prepared statement with bind vars to pr...
Go | 1 day ago | 3.67 KB
rc
2 days ago | 2.49 KB
Stripe Session Vars
2 days ago | 0.67 KB
[TLF 16] Hylandra's File / Introduction
2 days ago | 3.37 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!