Categories

move inventory condition redstone branch logic arithmetic relations text stack control misc

Contents

move

'forward', 'back', 'down', 'up' will move turtle in one direction until new tag is found.
'pushPostamble(function)' will make argument execute after any code from tag. Previous value is saved and can be restored with 'popPostamble'

NameIcon & colorLabelComment
startdouble-forwardStartOptional marker for start
Contents:pushPostamble(forward)
Description:Functionally identical to 'postamble-forward', but with different color to mark start
forwardforwardForwardStops on new tag
Contents:forward()
backforwardBackStops on new tag
Contents:back()
upforwardUpStops on new tag
Contents:up()
downforwardDownStops on new tag
Contents:down()
go-rightrightGo rightTurn and make single step
Contents:turnRight() t.forward()
go-leftleftGo leftTurn and make single step
Contents:turnLeft() t.forward()
turn-rightrightTurn right
Contents:turnRight()
turn-leftleftTurn left
Contents:turnLeft()
step-forwardforwardSingle step forward
Contents:t.forward()
step-backforwardSingle step back
Contents:t.back()
step-upforwardSingle step up
Contents:t.up()
step-downforwardSingle step down
Contents:t.down()
postamble-forwarddouble-forwardDefault move: forwardCall 'forward' after command from tag is executed
Contents:pushPostamble(forward)
postamble-backdouble-forwardDefault move: backCall 'back' after command from tag is executed
Contents:pushPostamble(back)
postamble-updouble-forwardDefault move: upCall 'up' after command from tag is executed
Contents:pushPostamble(up)
postamble-downdouble-forwardDefault move: downCall 'down' after command from tag is executed
Contents:pushPostamble(down)
orient-frontorient-frontOrient frontRotate turtle until tag is in front
Contents:orient('front')
orient-rightorient-rightOrient rightRotate turtle until tag is on the right side
Contents:orient('right')
orient-leftorient-leftOrient leftRotate turtle until tag is on the left side
Contents:orient('left')
orient-backorient-backOrient backRotate turtle until tag is on back
Contents:orient('back')
rotate-to-argrotate-cwRotate to argumentPop direction and rotate
Contents:rotate(pop())
move-to-argdirMove in directionStart moving into direction passed on stack
Contents:replacePostamble(pop())

inventory

Functions like 'suck' or 'drop' will automatically try to pick proper inventory - either rotate turtle, so he is facing tag or call ...Up/..Down versions of command.
Second argument of those functions is boolean, describing if turtle should restore its initial orientation

NameIcon & colorLabelComment
refuelenergyRefuelWill suck from inventory in tagged block
Contents:suck(tagDir, true) refuel()
suckoutSuck
Contents:suck(tagDir, true)
dropinDrop
Contents:drop(tagDir, true)
placeinPlacePlace block in front of turtle
Contents:t.place()
first-slotfirstSelect first slot
Contents:_slot = 1 select(_slot)
last-slotlastSelect last slot
Contents:_slot = 16 select(_slot)
next-slotnextSelect next slot
Contents:_slot = math.min(_slot + 1, 16) select(_slot)
prev-slotprevSelect previous slot
Contents:_slot = math.max(_slot - 1, 1) select(_slot)
push-slotpushPush current slot
Contents:push(_slot)
pop-slotpopSelect slot from stack
Contents:_slot = pop() select(_slot)
item-countquestionGet item count in slot
Contents:push(getItemCount(pop()))
item-count-currentquestionGet item count in current slot
Contents:push(getItemCount(_slot))

condition

Commands in this category will push result onto argument stack. 'compare' and 'detect' operate on block with tag (see notes for 'inventory')

NameIcon & colorLabelComment
comparequestionCompareResult on stack
Contents:push(compare(tagDir, true))
detectquestionDetectResult on stack
Contents:push(detect(tagDir, true))

redstone

Commands in this category will push result onto argument stack

NameIcon & colorLabelComment
redstone-getdustRead redstoneResult on stack
Contents:push(redstone.getAnalogInput(tagDir))
redstone-set-analogdustSet redstone output (analog)Argument on stack
Contents:redstone.setAnalogOutput(pop())
redstone-set-digitaldustSet redstone output (digital)Argument on stack
Contents:redstone.setOutput(pop())
push-redstone-dirpushPush signal dirPush redstone signal directions
Contents:push(scanRedstone())
redstone-waithourglassWait for redstoneWait for any redstone event
Contents:os.pullEvent('redstone')
redstone-wait-dirhourglassWait for redstone (sided)Wait for redstone signal from tag side
Contents:waitForRedstone(tagDir)
redstone-read-toppushRead top signalWait for redstone signal from tag side
Contents:push(rs.getInput('top'))

branch

Commands in this category use argument stack. Helper function 'cond(function, ...)' is equivalent to 'if pop() then function(...) end'

NameIcon & colorLabelComment
branch-leftbranchConditional leftCondition on stack
Contents:cond(turnLeft)
branch-rightbranchConditional rightCondition on stack
Contents:cond(turnRight)
branch-stopbranchConditional stopCondition on stack
Contents:if pop() then stop() return end
branch-skipbranchConditional skip next commandCondition on stack
Contents:cond(control.skip())
junctionbranchJunctionTurn left on true, right on false
Contents:if pop() then turnRight() else turnLeft() end

logic

Functions in this category operate on argument stack (pop needed arguments and push result back). For example: 'and_()' == 'push(pop() and pop())'

NameIcon & colorLabelComment
andtext!andLogical andArguments on stack
Contents:and_()
ortext!orLogical orArguments on stack
Contents:or_()
nottext!notLogical notArgument on stack
Contents:not_()

arithmetic

Functions in this category operate on argument stack (pop needed arguments and push result back)

NameIcon & colorLabelComment
zerodni-zeroPush zero
Contents:push(0)
onedni-onePush one
Contents:push(1)
twodni-twoPush two
Contents:push(2)
threedni-threePush three
Contents:push(3)
fourdni-fourPush four
Contents:push(4)
addtext!addAddArguments on stack
Contents:add()
subtext!subSubtractArguments on stack
Contents:sub()
multext!mulMuliplyArguments on stack
Contents:mul()
divtext!divDivideArguments on stack
Contents:div()
inctext!++IncrementArgument on stack
Contents:inc()
dectext!--DecrementArgument on stack
Contents:dec()
negtext!negNegateArgument on stack
Contents:neg()

relations

NameIcon & colorLabelComment
gttext!a>bGreater thanArguments on stack
Contents:gt()
lttext!a<bLess thanArguments on stack
Contents:lt()
eqtext!a==bEqualArguments on stack
Contents:eq()
neqtext!a!=bNot equalArguments on stack
Contents:neq()
lt0text!a<0Less than zeroArgument on stack
Contents:push(pop() < 0)
le0text!a<=0Less or equal zeroArgument on stack
Contents:push(pop() <= 0)
gt0text!a>0Greater than zeroArgument on stack
Contents:push(pop() > 0)
ge0text!a>=0Greater or equal zeroArgument on stack
Contents:push(pop() >= 0)
eq0text!a==0Equal to zeroArgument on stack
Contents:push(pop() == 0)
neq0text!a~=0Not equal to zeroArgument on stack
Contents:push(pop() ~= 0)
niltext!a == nilIs nil?Argument on stack
Contents:push(pop() == nil)

text

NameIcon & colorLabelComment
tostringtext!a->strConvert to stringArgument on stack
Contents:push(tostring(pop()))
tonumbertext!a->numConvert to numberArgument on stack
Contents:push(tonumber(pop()))
concattext!a..bConcatenateArgument on stack
Contents:concat()

stack

NameIcon & colorLabelComment
printquestionPrintPrint top of stack
Contents:print(top())
poppopPopPop top of stack
Contents:pop()
dupcopyDuplicateDuplicate top of stack
Contents:dup()
swapswapSwapSwap top stack elements
Contents:swap()
storeinStorePop index and store next stack value to slot[index]
Contents:store(pop())
loadoutLoadPop index and load value from slot[index]
Contents:load(pop())

control

NameIcon & colorLabelComment
repeatgearRepeatRepeat command from previously read tag
Contents:prev()
repeat-timesgearRepeat nRepeat command from previously read tag n times (value on stack)
Contents:for i=0,pop() do prev() end
postamble-prevpushPush default: prevExecute previous command after all tags
Contents:pushPostamble(prev)
Description:Command from previously read tag will be executed after any new one (including this)
postamble-pop-continuepopPop and call default
Contents:p = popPostamble() p()
Description:Restore previous postamble (command executed after tag) and call current one
postamble-poppopPop default
Contents:popPostamble()
Description:Restore previous postamble (command executed after tag)
postamble-disablepauseDisable postambleRestore with popPostamble()
Contents:pausePostamble()
Description:Temporarily disable postamble. Will repeat current postamble, since otherwise turtle would stop.
sleep-1hourglassSleep one second
Contents:sleep(1)
sleep-0.5hourglassSleep half second
Contents:sleep(0.5)
stopnoStopStop program execution
Contents:stop()
Description:Exit 'follow' program - no more tags will be read after that. All postambles are deactivated
recordrecordRecord macroAny next command will be appended to macro
Contents:!record
Description:Any encountered tag won't be executed, but will be added to command list. Use tag with '!save' to finish
record-executerecordRecord and execute macroAny next command will be executed and appended to macro
Contents:!record_execute
Description:Any encountered tag will be executed, but also added to command list. Use tag with '!save' to finish
skip-nextnextSkip next tagSkip any next tag
Contents:!skip
push-macropushSave macroRecorded macro will be pushed to stack. Start recording macro with 'record'
Contents:!save
Description:Recorded macro will be pushed to stack. Use 'call' to replay.
play-macroplayPlay macro (pop)Plays previously recorded macro (pop value from stack)
Contents:pop()()
play-keep-macroplayPlay macro (keep)Plays previously recorded macro (keep value on stack)
Contents:top()()
execute-pausepausePause command executionRestore execution with !restore
Contents:!pause
execute-restoreplayRestore command execution
Contents:!restore
postamble-macrogearSet macro as postambleSets previously recorded macro as postamble
Contents:pushPostamble(pop())
reader-disableoffStop reading tags
Contents:readTags=false
reader-enableonRestore reading tags
Contents:readTags=true
missing-ignoreonIgnore missing tags
Contents:ignoreMissing=true
missing-failoffStop on missing tags
Contents:ignoreMissing=false

misc

NameIcon & colorLabelComment
debug-onquestionDebug output on
Contents:debug(true)
Description:Will print informations like stack operations
debug-offquestionDebug output off
Contents:debug(false)
Description:Will print informations like stack operations
counter-inctext!tag[]++Increment current tagIncrement counter for tag and push to stack
Contents:counters.inc(serial)
Description:Counters are kept on turtle, so they can't be shared. Values do not persist between runs.
push-tag-dirpushPush tag dirPush current tag direction (relative to turtle)
Contents:push(tagDir)