Spis poleceń › Control — poleceń: 48
@
Wejście: primitivename
Wyjście: 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
Wejście: time-in-milliseconds (number) | requests (list)
Wyjście: 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
Wejście: none
Wyjście: none
Returns the age of the current turtle in milliseconds. Reset it with resetage
show age
show snappy:age
ask
Wejście: word or list | list
Wyjście: none
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
Wejście: none
Wyjście: 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
continue
Wejście: none
Wyjście: none
Skips the rest of the current loop iteration and continues with the next iteration of the loop.
repeat 10 [if repcount = 5 [continue] print repcount]
1
2
3
4
6
7
8
9
10
breakpoint
Wejście: none
Wyjście: none
Pauses all execution as if pressing the Pause button and drops into the pause console. exit resumes
breakpoint
calm
Wejście: turtle (word) or turtles (list)
Wyjście: none
Stops all workers running in the specified turtle(s). When called on a hatchling, it ceases to be. See halt
calm "snappy
calm [snappy myrtle]
co
Wejście: none
Wyjście: none
Continues execution if that execution was halted by the pause primitive. See pause.
co
control
Wejście: turtle (word) OR turtles (list) | primitives (list)
Wyjście: none
Executes the specified primitives using the specified turtle(s) 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]
control hatchlings [fd 20]
dawdle
Wejście: none
Wyjście: 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
Wejście: none
Wyjście: none
die halts the thread that calls it. Useful for terminating execution arbitrarily, although it should be done more gracefully, where possible.
die
eraseturtle
Wejście: name (word)
Wyjście: none
Erases the specified turtle
erase "fred
escape
Wejście: none
Wyjście: none
Allows the user to use the escape key to halt all execution. See noescape
escape
everyone
Wejście: none
Wyjście: 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
Wejście: none
Wyjście: 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
Wejście: worker (number) or workers (list)
Wyjście: none
Halts the specified worker or workers.
halt 7
halt [7 9]
interrupt
Wejście: turtle (word) | instructions (list)
Wyjście: 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]
linger
Wejście: none
Wyjście: none
Causes the calling turtle to sleep forever. It can still be controlled using the control primitive or turtlename:command, and if physical, will still respond to external forces. Useful for hatchlings used in physics contexts.
linger
listworkers
Wejście: none
Wyjście: none
Displays a list of operating workers.
listworkers
marco
Wejście: turtle (word)
Wyjście: 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
Wejście: none
Wyjście: list
Returns a list of all the turtles that have called marco on the calling turtle. See marco
show marcos
myworker
Wejście: none
Wyjście: id (number)
Returns the worker ID of the worker that calls it. See myworkers
show myworker
myworkers
Wejście: none
Wyjście: 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
Wejście: list
Wyjście: 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
Wejście: list
Wyjście: 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
Wejście: none
Wyjście: none
Disables the ability of the escape key to halt all execution. See escape
noescape
nosync
Wejście: none
Wyjście: none
Cancels a current sync. See sync
nosync
pacify
Wejście: none
Wyjście: none
Calms (stops) all turtles except for the turtle who calls pacify. See calm
pacify
polo
Wejście: turtle (word)
Wyjście: none
Calls polo on the specified turtle. See marco, marcop, marcos
polo "myrtle
request
Wejście: turtle [list of instructions]
Wyjście: 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
Wejście: none
Wyjście: none
Resets the current turtle's age. See age
resetage
resetsleep
Wejście: none
Wyjście: 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
Wejście: none
Wyjście: 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
Wejście: worker (number) or workers (list)
Wyjście: 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
Także: do
Wejście: list
Wyjście: 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
Wejście: list
Wyjście: 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
Wejście: milliseconds
Wyjście: 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
Wejście: none
Wyjście: 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
Wejście: none
Wyjście: none
Stops all threads running in the calling turtle except the thread executing solo, if that thread belongs to that turtle.
solo
stop
Wejście: none
Wyjście: 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
Wejście: worker (number) or workers (list)
Wyjście: 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
Wejście: none
Wyjście: 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
Wejście: 60ths-of-a-second (number)
Wyjście: 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
Wejście: id-number
Wyjście: boolean
Returns true if worker with id-number is running.
print workerp 123
workers
Wejście: none
Wyjście: list
Returns a list of running workers.
show workers
polos
Wejście: none
Wyjście: none
Related to the marco/polo debugging system. See marcos and marcop for more information.
polos
semaphore
Wejście: none
Wyjście: none
Creates or manages a semaphore for synchronization between workers.
semaphore