リファレンス › Control — 48 個のコマンド
@
入力: 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
入力: 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
入力: none
出力: none
Returns the age of the current turtle in milliseconds. Reset it with resetage
show age
show snappy:age
ask
入力: word or list | list
出力: 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
入力: none
出力: 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
入力: none
出力: 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
入力: none
出力: none
Pauses all execution as if pressing the Pause button and drops into the pause console. exit resumes
breakpoint
calm
入力: turtle (word) or turtles (list)
出力: 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
入力: none
出力: none
Continues execution if that execution was halted by the pause primitive. See pause.
co
control
入力: turtle (word) OR turtles (list) | primitives (list)
出力: 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
入力: 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
入力: 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
入力: name (word)
出力: none
Erases the specified turtle
erase "fred
escape
入力: none
出力: none
Allows the user to use the escape key to halt all execution. See noescape
escape
everyone
入力: 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
入力: none
出力: 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
入力: worker (number) or workers (list)
出力: none
Halts the specified worker or workers.
halt 7
halt [7 9]
interrupt
入力: 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]
linger
入力: none
出力: 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
入力: none
出力: none
Displays a list of operating workers.
listworkers
marco
入力: 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
入力: none
出力: list
Returns a list of all the turtles that have called marco on the calling turtle. See marco
show marcos
myworker
入力: none
出力: id (number)
Returns the worker ID of the worker that calls it. See myworkers
show myworker
myworkers
入力: 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
入力: 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
入力: 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
入力: none
出力: none
Disables the ability of the escape key to halt all execution. See escape
noescape
nosync
入力: none
出力: none
Cancels a current sync. See sync
nosync
pacify
入力: none
出力: none
Calms (stops) all turtles except for the turtle who calls pacify. See calm
pacify
polo
入力: turtle (word)
出力: none
Calls polo on the specified turtle. See marco, marcop, marcos
polo "myrtle
request
入力: 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
入力: none
出力: none
Resets the current turtle's age. See age
resetage
resetsleep
入力: none
出力: 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
入力: none
出力: 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
入力: worker (number) or workers (list)
出力: 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
別名: do
入力: 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
入力: 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
入力: milliseconds
出力: 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
入力: none
出力: 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
入力: none
出力: none
Stops all threads running in the calling turtle except the thread executing solo, if that thread belongs to that turtle.
solo
stop
入力: 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
入力: worker (number) or workers (list)
出力: 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
入力: 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
入力: 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. 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
入力: id-number
出力: boolean
Returns true if worker with id-number is running.
print workerp 123
workers
入力: none
出力: list
Returns a list of running workers.
show workers
polos
入力: none
出力: none
Related to the marco/polo debugging system. See marcos and marcop for more information.
polos
semaphore
入力: none
出力: none
Creates or manages a semaphore for synchronization between workers.
semaphore