control


@

Takes:   primitivename

Returns:   none

@ allows you to run the built-in primitive of the given primitivename, when there is a user-defined procedure with that name typically overriding it. See runprimitive

@forward 20


after

Takes:   time-in-milliseconds (number) | requests (list)

Returns:   none

After the specified amount of time the list of requests is performed by the current turtle in a new thread.

after 1000 [print [One second has passed.]]


age

Takes:   none

Returns:   none

Returns the age of the current turtle in milliseconds. Reset it with resetage

show age
show snappy:age


ask

Takes:   word or list | list

Returns:   Creates new workers for each specified turtle in the word or list, and causes them to execute the instructions in the following list. Existing workers are not interrupted and as such they may conflict!

ask “myrtle [fd 20]

ask [myrtle snappy] [fd 20]


break

Takes:   none

Returns:   none

‘Breaks’ or exits from the current loop, for example repeat or foreach, or run command, and continues execution.

repeat 10 [print repcount if repcount = 5 [break]] print "Broken!
1
2
3
4
5
Broken!

run [pr "one break pr "two]
one


calm

Takes:   turtle (word)

Returns:   turtles (list)

none

Stops all workers running in the specified turtle(s). See halt

calm "snappy
calm [snappy myrtle]


co

Takes:   none

Returns:   none

Continues execution if that execution was halted by the pause primitive. See pause.

co


control

Takes:   turtle (word) | primitives (list)

Returns:   none

Executes the specified primitives using the specified turtle in the thread that calls the control primitive. Same as executing turtle:run [do these things], but easier to automate. Also if a softlist is used it is evaluated on the side of the calling turtle, and so it uses the calling turtle’s containers (variables). For example: foreach “turtle everyone [control :turtle [fd 10]]

control "snappy [orbitleft 20]


dawdle

Takes:   none

Returns:   none

Waits until all of the turtle’s workers except for its ‘main’ one and / or hatchlings finish executing.

newworker [repeat 100 [wait 1]] dawdle print |Done waiting.|


die

Takes:   none

Returns:   none

die halts the thread that calls it. Useful for terminating execution arbitrarily, although it should be done more gracefully, where possible.

die


eraseturtle

Takes:   name (word)

Returns:   none

Erases the specified turtle

erase "fred


escape

Takes:   none

Returns:   none

Allows the user to use the escape key to halt all execution. See noescape

escape


everyone

Takes:   none

Returns:   list

Returns a list of all turtles except Snappy, which is a camera-only turtle. Useful to use with foreach to iterate through a series of instructions with each turtle.

show everyone
["myrtle]


finish

Takes:   none

Returns:   none

Halts all threads in all turtles. Disables all triggers. Stops the world. Clears keys left in the buffer. Can be invoked by pressing the escape key, unless noescape has been invoked.

finish


halt

Takes:   worker (number) or workers (list)

Returns:   none

Halts the specified worker or workers.

halt 7
halt [7 9]


interrupt

Takes:   turtle (word) | instructions (list)

Returns:   none

Stops all workers executing in the specified turtle, and creates another to preform the specified instructions. The interrupted execution does not resume after the instructions have been executed. Similar to arrest “turtle ask “turtle [instructions]

interrupt "snappy [orbitleft 90]


listworkers

Takes:   none

Returns:   none

Displays a list of operating workers.

listworkers


marco

Takes:   turtle (word)

Returns:   none

Marco causes the calling turtle to wait until the specified turtle calls polo. This allows for some simple synchronisation between turtles. See marcop, marcos, polo

marco "snappy


marcos

Takes:   none

Returns:   list

Returns a list of all the turtles that have called marco on the calling turtle. See marco

show marcos


myworker

Takes:   none

Returns:   id (number)

Returns the worker ID of the worker that calls it. See myworkers

show myworker


myworkers

Takes:   none

Returns:   list

Returns a list of the IDs of the workers belonging to the calling turtle or its hatchlings. Hatchlings do not own workers, only ‘root’ turtles. myworkers doesn’t return any results if called by a hatchling. See newworker, workers

show myworkers


newworker

Takes:   list

Returns:   none

creates a new ‘worker’ and executes the contents of the list of primitives or procedures provided to it.

newworker [forever [rt random 180 fd random 100]]


newworkerid

Takes:   list

Returns:   number

newworkerid creates a new worker the same as newworker, but acts as a function and returns the thread ID of the new worker.

show newworkerid [forever [rt random 180 fd random 100]]


noescape

Takes:   none

Returns:   none

Disables the ability of the escape key to halt all execution. See escape

noescape


nosync

Takes:   none

Returns:   none

Cancels a current sync. See sync

nosync


pacify

Takes:   none

Returns:   none

Calms (stops) all turtles except for the turtle who calls pacify. See calm

pacify


polo

Takes:   turtle (word)

Returns:   none

Calls polo on the specified turtle. See marco, marcop, marcos

polo "myrtle


request

Takes:   turtle [list of instructions]

Returns:   none

Performs the provided series of instructions once the specified turtle has no other workers executing. See interrupt for a more abrupt way of doing this

request "myrtle [sphere 50]


resetage

Takes:   none

Returns:   none

Resets the current turtle’s age. See age

resetage


resetsleep

Takes:   none

Returns:   none

Resets the sleep counters in a given worker. These counters contain the discrepancy values between occurrences of specific instances of the sleep primitive, and are used to average the speed of execution. See sleep, sleepover

resetsleep


rest

Takes:   none

Returns:   none

rest halts all workers running in the calling turtle. rest also terminates the calling turtle if it is a member of a bale or a hatchling. See die

rest


resume

Takes:   worker (number) or workers (list)

Returns:   none

Resumes execution of the specified worker(s). Can also take the value “archon, which is the primary thread. See suspend, newworker

resume 7


run

Takes:   list

Returns:   none

Executes the provided list of primitives. This allows you to use various word and list functions to dynamically generate turtleCode into a list which can then be executed.

make "square [repeat 4 [forward 20 right 90]]
run :square


runprimitive

Takes:   list

Returns:   none

Executes the provided list of primitives and procedures with primitives given precedence over procedures (the opposite of normal execution). For example, if you have a procedure named forward, it would ordinarily override attempts to execute the forward primitive. However, if you pass forward to runprimitive, runprimitive will execute the forward primitive in preference to your procedure. You can also accomplish the same effect as runprimitive by prefacing a primitive with @. See examples

runprimitive [forward 20]
@forward 20


sleep

Takes:   milliseconds

Returns:   none

Causes execution to pause for the specified number of milliseconds. Useful when working with time to calculate delays. If the parameter is provided in the form of a single-item list, sleep will instead attempt to average the given number of milliseconds between the times the specific instance of sleep is called, which is useful for providing consistent timing. Alternative to wait. See dosleep

sleep 1000
sleep [1000]


sleepover

Takes:   none

Returns:   milliseconds

Returns the number of milliseconds excess taken between occurrences of a sleep command provided with a single-item list parameter, eg sleep [50]. Useful for determining if a loop needs to be ‘dropped’ in order to ensure performance of a program. See sleep, sleepoverp

show sleepover


solo

Takes:   none

Returns:   none

Stops all threads running in the calling turtle except the thread executing solo, if that thread belongs to that turtle.

solo


stop

Takes:   none

Returns:   none

Stops execution inside the current procedure and returns to the level above, if it exists, or stops execution of the thread entirely.

stop


suspend

Takes:   worker (number) or workers (list)

Returns:   none

Suspends execution of the specified worker(s). Can also take the value “archon, which is the primary thread. See resume, newworker

suspend 7


sync

Takes:   none

Returns:   none

Causes turtle to wait until all other turtles in its ‘family’ (siblings, parents, hatchlings) also call sync, or if any of them call a nosync. Commonly used to synchronise multithreaded hordes of game objects, such as enemies. See syncp, nosync, marco

ht repeat 20 [hatch [forever [randomvectors fd 10 sync]]] forever [until syncp [wait 60] sync]


wait

Takes:   60ths-of-a-second (number)

Returns:   none

Pauses execution for the amount of time specified in 60ths of a second. wait 60 pauses for one second. If the parameter is provided in the form of a single-item list, wait will instead attempt to average the given number of 60ths of a second between the times the specific instance of wait is called, which is useful for providing consistent timing. See sleep, dosleep

wait 60
wait [60]


workerp

Takes:   id-number

Returns:   boolean

Returns true if worker with id-number is running.

print workerp 123


workers

Takes:   none

Returns:   list

Returns a list of running workers.

show workers