control
@
control
primitivename
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
control
time-in-milliseconds (number) | requests (list)
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
control
none
none
Returns the age of the current turtle in milliseconds. Reset it with resetage
show age
show snappy:age
ask
control
word or list | list
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
control
none
none
‘Breaks’ or exits from the current loop, for example repeat or foreach, and continues execution.
repeat 10 [print repcount if repcount = 5 [break]] print "Broken!
1
2
3
4
5
Broken!
calm
control
turtle (word)
turtles (list)
none
Stops all workers running in the specified turtle(s). See halt
calm "snappy
calm [snappy myrtle]
co
control
none
none
Continues execution if that execution was halted by the pause primitive. See pause.
co
control
control
turtle (word) | primitives (list)
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, for example: foreach “turtle everyone [control :turtle [fd 10]]
control "snappy [orbitleft 20]
dawdle
control
none
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
control
none
none
die halts the thread that calls it. Useful for terminating execution arbitrarily, although it should be done more gracefully, where possible.
die
eraseturtle
control
name (word)
none
Erases the specified turtle
erase "fred
escape
control
none
none
Allows the user to use the escape key to halt all execution. See noescape
escape
everyone
control
none
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
control
none
none
Halts all threads in all turtles. Stops the world. Can be invoked by pressing the escape key, unless noescape has been invoked.
finish
halt
control
worker (number) or workers (list)
none
Halts the specified worker or workers. The worker(s) must be owned by the turtle calling halt.
halt 7
halt [7 9]
interrupt
control
turtle (word) | instructions (list)
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
control
none
none
Displays a list of operating workers.
listworkers
marco
control
turtle (word)
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
control
none
list
Returns a list of all the turtles that have called marco on the calling turtle. See marco
show marcos
myworker
control
none
id (number)
Returns the worker ID of the worker that calls it. See myworkers
show myworker
myworkers
control
none
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
control
list
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
control
list
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
control
none
none
Disables the ability of the escape key to halt all execution. See escape
noescape
nosync
control
none
none
Cancels a current sync. See sync
nosync
pacify
control
none
none
Calms (stops) all turtles except for the turtle who calls pacify. See calm
pacify
polo
control
turtle (word)
none
Calls polo on the specified turtle. See marco, marcop, marcos
polo "myrtle
request
control
turtle [list of instructions]
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
control
none
none
Resets the current turtle’s age. See age
resetage
resume
control
worker (number) or workers (list)
none
Resumes execution of the specified worker(s). See suspend, newworker
resume 7
run
control
list
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
control
list
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
control
milliseconds
none
Causes execution to pause for the specified number of milliseconds. Useful when working with time to calculate delays. Alternative to wait.
sleep 1000
solo
control
none
none
Stops all threads running in the calling turtle except the thread executing solo, if that thread belongs to that turtle.
solo
stop
control
none
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
control
worker (number) or workers (list)
none
Suspends execution of the specified worker(s). See resume, newworker
suspend 7
sync
control
none
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
control
60ths-of-a-second (number)
none
Pauses execution for the amount of time specified in 60ths of a second. wait 60 pauses for one second.
wait 60
workerp
control
id-number
boolean
Returns true if worker with id-number is running.
print workerp 123
workers
control
none
list
Returns a list of running workers.
show workers