Referencia › Control — 48 comandos


@

control

Entrada: primitivename
Salida: 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

Entrada: time-in-milliseconds (number) | requests (list)
Salida: 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

Entrada: none
Salida: none

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

show age
show snappy:age

ask

control

Entrada: word or list | list
Salida: 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

control

Entrada: none
Salida: 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

control

Entrada: none
Salida: 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

control

Entrada: none
Salida: none

Pauses all execution as if pressing the Pause button and drops into the pause console. exit resumes

breakpoint

calm

control

Entrada: turtle (word) or turtles (list)
Salida: 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

control

Entrada: none
Salida: none

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

co

control

control

Entrada: turtle (word) OR turtles (list) | primitives (list)
Salida: 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

control

Entrada: none
Salida: 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

Entrada: none
Salida: 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

Entrada: name (word)
Salida: none

Erases the specified turtle

erase "fred

escape

control

Entrada: none
Salida: none

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

escape

everyone

control

Entrada: none
Salida: 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

Entrada: none
Salida: 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

control

Entrada: worker (number) or workers (list)
Salida: none

Halts the specified worker or workers.

halt 7
halt [7 9]

interrupt

control

Entrada: turtle (word) | instructions (list)
Salida: 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

control

Entrada: none
Salida: 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

control

Entrada: none
Salida: none

Displays a list of operating workers.

listworkers

marco

control

Entrada: turtle (word)
Salida: 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

Entrada: none
Salida: list

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

show marcos

myworker

control

Entrada: none
Salida: id (number)

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

show myworker

myworkers

control

Entrada: none
Salida: 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

Entrada: list
Salida: 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

Entrada: list
Salida: 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

Entrada: none
Salida: none

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

noescape

nosync

control

Entrada: none
Salida: none

Cancels a current sync. See sync

nosync

pacify

control

Entrada: none
Salida: none

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

pacify

polo

control

Entrada: turtle (word)
Salida: none

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

polo "myrtle

request

control

Entrada: turtle [list of instructions]
Salida: 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

Entrada: none
Salida: none

Resets the current turtle's age. See age

resetage

resetsleep

control

Entrada: none
Salida: 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

control

Entrada: none
Salida: 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

control

Entrada: worker (number) or workers (list)
Salida: 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

También: do

control

Entrada: list
Salida: 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

Entrada: list
Salida: 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

Entrada: milliseconds
Salida: 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

control

Entrada: none
Salida: 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

control

Entrada: none
Salida: none

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

solo

stop

control

Entrada: none
Salida: 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

Entrada: worker (number) or workers (list)
Salida: 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

control

Entrada: none
Salida: 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

Entrada: 60ths-of-a-second (number)
Salida: 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

control

Entrada: id-number
Salida: boolean

Returns true if worker with id-number is running.

print workerp 123

workers

control

Entrada: none
Salida: list

Returns a list of running workers.

show workers

polos

control

Entrada: none
Salida: none

Related to the marco/polo debugging system. See marcos and marcop for more information.

polos

semaphore

control

Entrada: none
Salida: none

Creates or manages a semaphore for synchronization between workers.

semaphore