- lockaxis
- nolockaxis
- addvelocity
- advancephysics
- affix
- angularfriction
- anglethreshold
- angularvelocity
- appendblockmap
- beginblockmap
- blockmap
- blockmapsubtract
- blockmissiles
- brake
- buildblockmap
- clearblockmap
- collidedwith
- complexmodel
- deferphysics
- deflectedby
- deletescene
- elastic
- elasticity
- endblockmap
- endblockmapsubtract
- forces
- friction
- gravity
- gravitypoints
- hitby
- hitmissiles
- hitobjects
- hitpos
- hittest
- hull
- listscenes
- maxvelocity
- mechanical
- mass
- maxangularvelocity
- myforces
- newscene
- noaffix
- noblockmap
- nodeferphysics
- nogravity
- noreorient
- notorque
- pausephysics
- phantom
- physical
- physicsinterval
- physicsspeed
- positionthreshold
- reorient
- resumephysics
- scene
- scenes
- selectscene
- setangularfriction
- setanglethreshold
- setangularvelocity
- setelasticity
- setforces
- setfriction
- setgravitypoints
- setmass
- setmaxangularvelocity
- setmaxvelocity
- setmyforces
- setphysicsinterval
- setphysicsspeed
- setpositionthreshold
- setsurfacefriction
- setvelocity
- setvelocityheading
- simplemodel
- stabilize
- static
- surfacefriction
- thrust
- torque
- twist
- velocity
- velocityheading
- updatephysics
lockaxis
Takes: axis (word)
Returns: none
Causes the physics engine to lock the calling turtle to the specified axis — it cannot move the turtle along that axis, making it one dimensional. The parameter can be “x or “y. nolockaxis turns it off. See lockaxisp.
lockaxis “x
nolockaxis
Takes: word (“x or “y)
Returns: none
Disables the specified lockaxis.
nolockaxis “x
addvelocity
Takes: heading | turtle-units / second
Returns: none
Adds velocity to the calling turtle. See velocity
addvelocity 90 20
advancephysics
Takes: number
Returns: none
If pausephysics is enabled, advances the physics engine by the given number of seconds. See pausephysics
advancephysics 1/60
affix
Takes: none
Returns: none
Causes the turtle’s position to be unchangeable by the physics engine. See noaffix, affixp
affix
angularfriction
Takes: none
Returns: number
Returns the angular friction, or the percentage the turtle’s angular velocity (torque) is diminished per second. See setangularfriction
show angularfriction
5
anglethreshold
Takes: none
Returns: degrees (number)
Returns the current angle threshold, or the number of degrees the representation of a turtle in the physics engine must turn before it is reflected in the graphical representation of the turtle. This is a global setting that affects all turtles.
show anglethreshold
angularvelocity
Takes: none
Returns: number
Returns the degrees per second of angular velocity (rotation) in the calling turtle. Note that changing the turtle’s heading zeroes its angularvelocity. See setangularvelocity, twist, stabilize
show angularvelocity
appendblockmap
Takes: none
Returns: none
Adds to the blockmap. The appending turtle does not need to be the turtle that created the existing blockmap. endblockmap ceases adding to the blockmap. See beginblockmap
appendblockmap
beginblockmap
Takes: none
Returns: none
Outlines of shapes created by the calling turtle after beginblockmap is declared are added to the ‘blockmap’, a shadow representation used by the physics engine to detect collisions with defined areas in the environment. ‘Elastic’ turtles will deflect from the blockmap, other turtles may be blocked if they declare ‘blockmap’; it can also be detected using blocktestp. endblockmap ceases adding shapes to the blockmap
Declaring beginblockmap again erases the existing blockmap. To add more to the blockmap, use appendblockmap
Parts of the blockmap take on the current elasticity of the turtle who added them. This enables the creation of an environment with areas of varied elasticity. See endblockmap, blockmap, blocktestp
beginblockmap
blockmap
Takes: none
Returns: none
Causes the turtle to be ‘blocked’ by the blockmap, regardless of physics mode. To work, the turtle must have a model, and that model must be shown. A ‘hitbox’ of the model is created when blockmap is called. See noblockmap, which turns it off
blockmap
blockmapsubtract
Takes: none
Returns: none
An opening tag (with companion closing tag endblockmapsubtract) that attempts to remove the shapes created within it from the blockmap. However, it currently cannot remove shapes that lie entirely inside other shapes, it can only modify those shapes’ edges. See endblockmapsubtract, blockmap
blockmapsubtract
blockmissiles
Takes: class
Returns: list
Returns a list of missiles of the given class blocked by the blockmap since last read. See blockmissilep
show blockmissiles
brake
Takes: number
Returns: none
Causes the velocity of the calling turtle to diminish by the specified percentage (100 = full stop). See thrust
brake 50
buildblockmap
Takes: none
Returns: none
Build (or rebuild) the blockmap based on the calling turtle’s track. If you want to build the blockmap continually or incrementally use beginblockmap instead. See blockmap
buildblockmap
clearblockmap
Takes: none
Returns: none
Clears the blockmap. See beginblockmap
clearblockmap
collidedwith
Takes: none
Returns: list
Returns a list of turtles the physical calling turtle has intersected with since last read.
show collidedwith
complexmodel
Takes: none
Returns: none
Generates multiple linked physics bodies based on the different elements within the turtle’s model. This allows for concave physical models such as crescents or propellers. For simpler models such as spheres or squares, simplemodel is more appropriate (and less resource-intensive). See simplemodel
complexmodel
deferphysics
Takes: none
Returns: none
Suspends (defers) participation of the calling turtle in the physics engine without affecting its physical state — if it’s moving, you can ‘pause’ it using deferphysics, and then call nodeferphysics to resume its movement at a later point. See nodeferphysics, and pausephysics, which does this globally (for all turtles)
deferphysics
deflectedby
Takes: none
Returns: list
Returns a list of turtles (if any) that have deflected (or been deflected by) the calling turtle since deflectedby was last read. See deflectedp
show deflectedby
deletescene
Takes: name (word)
Returns: none
Deletes a scene. Members of the scene return to the ‘home’ scene. See newscene, selectscene
deletescene “scene
elastic
Takes: none
Returns: none
Makes a turtle ‘elastic’, which is a participant in the physics engine that deflects off of other elastic and mechanical turtles, objects and the blockmap. Elastic turtles have a ‘hitbox’ generated based on their model which identifies their bounds. Hidden elastic turtles are still subject to forces / gravity / velocity but are otherwise insubstantial — they do not deflect off of other turtles, objects or the blockmap, and nor do other turtles or objects bounce off of them, as they have no ‘hitbox’. Note that if they are declared elastic before shown, they will not separate from overlapping elastic objects, and as such elastic should be declared after they are shown. See physical, mechanical, phantom, static
elastic
elasticity
Takes: none
Returns: number
Returns the calling turtle’s ‘elasticity’, or the percentage of force that is transferred from the turtle to other turtles, objects or the blockmap. These items may themselves, depending on their elasticity, transfer force back to the turtle, causing it to repel or ‘bounce’. See setelasticity
show elasticity
endblockmap
Takes: none
Returns: none
‘Closes’ the blockmap. Shapes subsequently created are not added to the blockmap. To add to the blockmap later, use appendblockmap. See beginblockmap
endblockmap
endblockmapsubtract
Takes: none
Returns: none
An ending tag (with companion opening tag blockmapsubtract) that attempts to remove the shapes created within it from the blockmap. However, it currently cannot remove shapes that lie entirely inside other shapes, it can only modify those shapes’ edges. See endblockmapsubtract, endblockmap
endblockmapsubtract
forces
Takes: none
Returns: [[[vector] OR heading | turtle-units / second]] (list of lists)
Returns the current list of global ‘forces’, or directional effects on physical and elastic turtles. See setforces, setmyforces, myforces
show forces
friction
Takes: none
Returns: number
Returns the percentage (per second) that the turtle’s velocity is diminished by friction. See setfriction
show friction
gravity
Takes: none
Returns: none
Causes the mass of the calling turtle to affect other turtles and be affected by gravitypoints and/or the mass of other turtles. This is off by default. A turtle must be physical to be affected by gravity. See nogravity, gravitypoints, setmass
gravity
gravitypoints
Takes: none
Returns: [[[position] mass][[position] mass]…] (list)
Returns the current list of gravity points (global). See setgravitypoints
show gravitypoints
hitby
Takes: none
Returns: list
Returns a list of turtle(s) currently contacting (touching) the calling turtle. See hitp, which detects collisions. For a similar list of turtles that have previously contacted the calling turtle, see deflectedby, collidedwith.
show hitby
hitmissiles
Takes: class OR [class1 class2…]
Returns: list
Returns a list of missiles of the given class(es) that have contacted the calling turtle since last read. If an empty list is provided, returns missiles of all classes. See hitmissilep, which detects contacts (collisions).
show hitmissiles
hitobjects
Takes: class
Returns: list
Returns a list of objects of the given class collided with by the calling turtle since last read. See hitobjectp, a boolean which detects collisions.
show hitobjects
hitpos
Takes: position
Returns: list
Returns the names of turtles other than the calling turtle whose physics bodies (hulls) overlap the given location. See hittestp, which returns true if there are other turtles present at that location.
show hitpos [30 60]
hittest
Takes: heading distance
Returns: list
Returns the names of turtles other than the calling turtle whose physics bodies (hulls) overlap the given location. See hittestp, which returns true if there are other turtles present at that location.
show hittest 90 20
hull
Takes: none
Returns: list
Returns the dimensions of the turtles hitbox, or hull.
show hull
listscenes
Takes: none
Returns: none
Prints out a list of the current scenes. See selectscene, newscene
listscenes
maxvelocity
Takes: none
Returns: number
Returns the turtles ‘maxvelocity’ or the maximum turtle-units the physics engine may nove the turtle per second. See setmaxvelocity
show maxvelocity
mechanical
Takes: none
Returns: none
Makes a turtle ‘mechanical’. Mechanical turtles are represented in the physics engine but are not affected by forces such as elasticity, velocity or torque. They do not themselves move in response to collisions or forces, but do act to block or impart force on those turtles that collide with them. See elastic, physical, phantom
mechanical
mass
Takes: none
Returns: number
Returns the mass of the calling turtle in kilograms (default 10kg). See setmass
show mass
maxangularvelocity
Takes: none
Returns: number
Returns the turtle’s maximum angular (rotational) velocity. See setmaxangularvelocity to set it
show maxangularvelocity
myforces
Takes: none
Returns: [[[vector] OR heading | turtle-units / second]] (list of lists)
Returns the current list of forces affecting the calling turtle specifically. See setmyforces, forces
show myforces
newscene
Takes: name (word)
Returns: none
Creates a scene of the given name. Scenes are distinct physical spaces. See selectscene (which selects it).
newscene “scene
noaffix
Takes: none
Returns: none
Removes affix from the calling turtle. See affix
noaffix
noblockmap
Takes: none
Returns: none
Disables ‘blocking’ of the calling turtle by the blockmap. See blockmap, beginblockmap
noblockmap
nodeferphysics
Takes: none
Returns: none
Resumes participation in the physics engine by the calling turtle, which was suspended by deferphysics. See deferphysics
nodeferphysics
nogravity
Takes: none
Returns: none
Disables gravity on the calling turtle. See gravity, gravitypoints, mass
nogravity
noreorient
Takes: none
Returns: none
Disables reorient. See reorient.
noreorient
notorque
Takes: none
Returns: none
Disables torque (rotational velocity) on the calling turtle. See torque
notorque
pausephysics
Takes: none
Returns: none
Suspends the physics engine, and all its effects on turtles, objects and missiles. This includes blockmap collisions. See resumephysics
pausephysics
phantom
Takes: none
Returns: none
Makes a physical turtle ordinary. ‘phantom’ is the default turtle state, it does not have a representation in the physics engine. See elastic, physical, mechanical
phantom
physical
Takes: none
Returns: none
Makes a turtle ‘physical’. Physical turtles have a representation in the physics engine and can be impacted by forces and gravity (if enabled) but are NOT deflected nor exert force on other turtles (eg not elastic). Intersections with other turtles can be detected with collidedp, collidedwith. To be blocked by the blockmap, ‘blockmap’ must be declared. See elastic, phantom, mechanical
physical
physicsinterval
Takes: none
Returns: number
Returns the current physics ‘interval’, the time between internal updates of the physics model. See setphysicsinterval, which sets it.
show physicsinterval
physicsspeed
Takes: none
Returns: number
Returns the current physics speed, see setphysicsspeed
show physicsspeed
positionthreshold
Takes: none
Returns: number
Returns the position threshold, or the distance the physics representation of a turtle must move before it is updated in its graphical representation. See setpositionthreshold
show positionthreshold
reorient
Takes: none
Returns: none
Causes the turtle to face the direction of its current velocity, eg the velocityheading. noreorient turns it off.
reorient
resumephysics
Takes: none
Returns: none
Resumes processing of the physics engine. See pausephysics
resumephysics
scene
Takes: none
Returns: word
Returns the turtle’s current ‘scene’ or physical space. The default scene is ‘home’. Members of the same scene interact physically with each other — members do not interact with members from other scenes. Each scene also has its own blockmap — this is useful for multi-layered constructions. See selectscene, newscene, deletescene, scenes.
show scene
scenes
Takes: none
Returns: list
Returns a list of the currently active ‘scenes’, or physical spaces. The default scene is ‘home’. See listscenes, scenes, selectscene
show scenes
selectscene
Takes: word (name)
Returns: none
Selects the turtle’s current ‘scene’ or physical space from those available. The default scene is ‘home’. New scenes can be created with newscene. Members of the same scene interact physically with each other — members do not interact with members from other scenes. Each scene also has its own blockmap — this is useful for multi-layered constructions. See newscene, deletescene, scenes.
selectscene “city
setangularfriction
Takes: number
Returns: none
Sets the angular friction, or the percentage the turtle’s angular velocity (torque) is diminished per second. See sngularfriction
setangularfriction 5
setanglethreshold
Takes: none
Returns: degrees (number)
Sets the threshold at which angular changes in the physics models are reflected in their graphical counterparts. The physics model must turn at least the given number of degrees before the graphical model turns. This helps improve performance. This is a global setting that affects all turtles using the physics engine. See setpositionthreshold, which does similar with position
setanglethreshold 10
setangularvelocity
Takes: number
Returns: none
Sets the angular velocity of the calling turtle, or the rate of rotation, in degrees per second. If the value provided is negative, the turtle spins counterclockwise. See angularvelocity, torque, twist and stabilize
setangularvelocity 90
setelasticity
Takes: number
Returns: none
Sets the calling turtle’s ‘elasticity’, or the percent of force that is transferred from the turtle to other turtles, objects or the blockmap. These items may themselves, depending on their elasticity, transfer force back to the turtle, causing it to repel or ‘bounce’. See elasticity
setelasticity 100
setforces
Takes: [[[vector] OR heading | turtle-units / second]] (list of lists)
Returns: none
Sets global ‘forces’, or constant directional effects on physical and elastic turtles. In contrast to gravitypoints, which attract to specific locations, forces drag turtles in a specific direction regardless of location. This can be useful for platform games that need downward ‘gravity’, for example.
Forces are affected by mass inversely — the higher the mass of a turtle, missile or object the longer the effect takes to reach maximum influence. See setnass
Note that setforces takes a list of lists, so that multiple forces can be set at one time. See forces, setmyforces (which work on individual turtles) and myforces
Also note that turtles / objects closely aligned on the boundaries of their physics models may be forced through each other if forces are set sufficiently high (allow a bit of space!)
setforces [[180 50]]
setfriction
Takes: number
Returns: none
Sets the friction, or the percentage the turtle’s velocity is diminished per second. See friction
setfriction 5
setgravitypoints
Takes: [[[position] mass][[position] mass]…] (list of lists)
Returns: none
Sets the ‘gravity points’, a list of locations in turtle space that have associated mass, which affects turtles with gravity enabled. Note that these can be set negative, to repulse gravity turtles. See gravity, gravitypoints
setgravitypoints {{position 10^15}}
setmass
Takes: number
Returns: none
Sets the mass of the calling turtle in kilograms (kg). This is used with elasticity, gravity and forces to determine their affects on the turtle, and its affect on others. The default mass of a turtle is 10. See gravity, setforces, setgravitypoints
setmass 500
setmaxangularvelocity
Takes: number
Returns: none
Sets the maximum angular (rotational) velocity of the calling turtle, in degrees / second. This is the fastest the turtle will rotate. See maxangularvelocity
setmaxangularvelocity 90
setmaxvelocity
Takes: number
Returns: none
Sets the maximum velocity of the calling turtle, in turtle-units / second. This is the fastest the turtle can be moved by the physics engine. See maxvelocity
setmaxvelocity 100
setmyforces
Takes: [[[vector] OR heading | turtle-units / second]] (list of lists)
Returns: none
Sets local (or turtle-specific) forces, or constant directional effects on physical and elastic turtles. In contrast to gravitypoints, which attract to specific locations, forces drag turtles in a specific direction regardless of location. This can be useful for platform games that need downward ‘gravity’, for example. This command only works on the calling turtle, for global forces, see setforces
setmyforces [[90 50]]
setphysicsinterval
Takes: number
Returns: none
Sets the physics interval, or the time between updates of the internal physics model. The lower the value, the higher the accuracy. Note that increasing this value may cause collision detection to work imprecisely (balls may travel through walls, for example, in the ‘time’ between updates). Defaults to 1/60th of a second. See physicsinterval, which returns the current value
setphysicsinterval 1/20
setphysicsspeed
Takes: number
Returns: none
Allows the user to specify a fixed time increment to apply to the physics engine during each update, rather than the default “delta-t” of the elapsed real-world time (0). This is useful for using the physics engine for drawing operations to ensure accuracy. See physicsspeed
setphysicsspeed 1
setpositionthreshold
Takes: number
Returns: none
Sets the ‘threshold’ (in turtle-units) at which the physics engine updates the turtle positions in the environment. The internal physics model of the turtle must move the given number of turtle-units in order for its graphical representation to be updated. This is a global setting that affects all turtles. This improves performance at the expense of frame rate. See positionthreshold
setpositionthreshold 5
setsurfacefriction
Takes: number
Returns: none
Sets the current surface friction value, which indicates how much velocity is lost as a percentage over time when the calling turtle’s physics body contacts another. Note that missiles and objects inherit surfacefriction (and other friction values) from their parent turtle. See surfacefriction
seturfacefriction 20
setvelocity
Takes: number
Returns: none
Sets the calling turtle’s velocity, using the current velocityheading, or the turtle’s forward direction if no current velocityheading exists. See velocityheading, velocity, thrust
setvelocity 50
setvelocityheading
Takes: heading
Returns: none
Sets the calling turtle’s velocity heading, that is, the direction it is currently being moved by the physics engine. If the turtle is not moving, the set value will be used by setvelocity, or overwritten by thrust.
setvelocityheading 180
simplemodel
Takes: none
Returns: none
Generates a simple single physics body for the turtle model, tracing a convex shape around all of the elements in the model. For the ability to have concave turtle models, declare complexmodel. See complexmodel
simplemodel
stabilize
Takes: number (percentage)
Returns: none
Decreases the angularvelocity of a turtle by the given number, a percentage. So, stabilize 50 will cut the angularvelocity in half. See setangularvelocity, torque, brake (which does similar with velocity)
stabilize 50
static
Takes: none
Returns: none
static is a physical turtle type for turtles that are not expected to move. They are the lowest maintenance for the physics engine generally but are the most expensive in terms of resources to move. See mechanical, elastic, physical
static
surfacefriction
Takes: none
Returns: number
Returns the current surface friction value, which indicates how much velocity is lost as a percentage over time when the calling turtle’s physics body contacts another. See setsurfacefriction
show surfacefriction
thrust
Takes: number (turtle-units / second)
Returns: none
Adds velocity to the turtle in the current forward direction. Will make turtle ‘elastic’ if not currently a physical turtle (phantom). See addvelocity, brake
thrust 100
torque
Takes: none
Returns: none
Enables ‘torque’ or angularvelocity to be modified on the calling turtle when it collides with other turtles, objects, missiles or the blockmap. See notorque, which turns it off.
torque
twist
Takes: deg / second (number)
Returns: none
Increases angular velocity by the given amount. Use negative to increase it counterclockwise. Will make turtle ‘elastic’ if not already a physical turtle. See stabilize, which slows / stops it.
velocity
Takes: none
Returns: number (turtle-units / second)
Returns the current velocity of the calling turtle. Note that calling setpos(ition) on a moving turtle zeroes its velocity. See addvelocity, thrust
show velocity
velocityheading
Takes: none
Returns: degrees
Returns the current heading (direction) the calling turtle is being moved in by its velocity.
show velocityheading
updatephysics
Takes: none
Returns: none
Forces a synchronization of a turtle’s state with that of its body inside of the physics engine. Useful when positionthreshold is set relatively high, to update the turtle’s position when colliding with other turtles, for example. See setpositionthreshold
updatephysics