Scripting

**Scripting in Anyland** is a combination of "When \_\_\_ then \_\_\_" statements. Below is a tutorial on how to do this.

Each piece of code starts with When. Then you follow it up with a Then script.

## States

States are the keyframes of **Anyland** creations. Players can customize many aspects of a shape in individual shapes to create animations for the shapes.

Each Thing Part has a maximum 50 states, with a maximum of 50 scripts per state. The become script can make a Part become a different state. Each state can have a different material color, particle color, and texture color. However, the material, texture, and particle layers stay the same through the states.

## Variables

Variables allow you to save information in a thing, a person, or an area.

## When

* Starts - Triggers when the state starts.
* Touched - Triggers when the part is touched by a hand or held thing, or when a grabbable thing is let go and touches another object.
* Touches [thing name] - Triggers when touched by a thing of that name.
* Shaken - When a holdable thing is picked up and shaken.
* Triggered - Triggers when the controller trigger is pressed.
* Neared - Triggers when someone stands near this.
* Gets [name] - Takes something when touched by it
* Told - Triggers when getting a "tell" message from another part
* Told by nearby - Also receives messages from other things nearby.
* Told by any - Also receives messages from other things in the whole area.
* Told by body - Only receives messages from parts of this body.
* Consumed - Triggers when the thing is close to the mouth
* Walked into - Triggers when one teleports on something or walks into it
* Pointed at - Triggers when one points the index finger at this part
* Looked at - When one looks directly at this part
* Taken - When the holdable thing is picked up
* Grabbed - When a non-holdable but grabbable thing is grabbed (like a door knob)
* Talked from - Triggers one's head when one is speaking
* Talked to - triggers when one looks at this and speaks
* Blown at - When one blows at something or makes sound while it is near their mouth
* Turned around - When a holdable is turned onto its head (upside down)
* High speed - Triggers when a holdable thing is moved at high speed
* Let go - Triggers when a holdable thing is dropped or thrown
* Raised - Triggers when one raises up a holdable
* Lowered - Triggers when one lowers down a holdable
* Hit - When hit by something at high speed
* Hitting [thing name] - When hitting or being hit by something of that name at high speed
* Someone in vicinity - Triggers when someone gets in vicinity
* Someone new in vicinity - Triggers when someone new to the vicinity is in the vicinity (resets every time they exit the area)
* Touch ends - When someone stops touching the object
* Trigger let go - Triggers when a holdable thing is held and someone stops pressing the trigger
* Destroyed - Triggers when anything ends, such as a mug shattering.
* Destroyed restores - When a "Destroy all parts with 30S" type placement restores.
* Any state - Applies to all states of this part.
* Any part - Inserted between "When" and the trigger, this makes the trigger listen to actions done to any part of the object or sub-things, rather than just the shape it was coded on.
* Hears [speech] - When this is spoken in vicinity (when attached, spoken by oneself)
* Typed - When text was typed. Can be attached and used with "Say [Typed]".

* Is - When a value changes (You can also use when touched and is...).

## Then

* Become [state] - Goes to the state of that number.
* Play [sound name] - Plays a sound from 1,300+ sounds.
* Play track [play to record] - Starts recording when selected. Play on any Anyland instrument.
* Play [instrument] - Play a note with a tone generator or instrument.
* Tell - Sends a message, which other parts can receive using "told".
* Tell nearby - Also sends a message to other things nearby.
* Tell any - Also sends messages to any thing in the whole area.
* Tell body - If attached, sends message to other parts of this body and holdables.
* Tell first of any - Sends a message to the closest reacting other thing.
* Tell web - Send a command to an web screen on this thing.
* Tell any web - Send a command to all web screens in the area.
* Send nearby to [area name] - Sends a nearby person to the area specified.
* Send nearby onto [thing name] - Transports a nearby person to the closest thing with the specified name.
* Send one nearby to [area name] - Yourself and attachments teleport to the specified area.
* Send one nearby onto [thing name] - Transports one onto the closest object with the specified name.
* Send all to [area name] - Placements and attachments transport there.
* Send all onto [thing name] - Sends everyone onto the closest thing of that name.
* Is - Sets a variable.
* Loop [name] - Loops a sound until "end loop" is used.
* End loop - Ends the current sound loop started with "loop".
* Call me - Names this part's state, other parts could use it as "when touched by [name].
* Let go - Drops the item if currently held.
* Emit [thing from inventory] - Emits the included thing with a given speed.
* Emit gravity-free [thing from inventory] - Emits something at a given speed with no gravity.
* Destroy all parts - Removes the whole thing (if it was dropped or thrown).
* Destroy nearby - Destroys other things nearby at a given radius to surfaces and maximum thing size.
* Give haptic feedback - Gives a haptic buzz to the person holding it.
* All parts face someone - Rotates the entire object towards the head of the closest person.
* All parts face someone else - Rotates the entire object towards the head of the second-closest person.
* All parts face up - rotates the whole thing upwards
* All parts face empty hand - Rotates towards the closest empty hand.
* All parts face empty hand while held - Rotates towards the closest empty hand while being held.
* All parts face nearest [thing name] - Rotates towards the closest thing of that name.
* Stop all parts face someone - Stops rotating towards closest or second-closest person.
* Stop all parts face empty hand - Stops rotating towards the empty hand.
* Stop all parts face up - Stops rotating the whole thing upwards.
* Stop all parts face nearest - Stops rotating towards the closest thing of that name.
* Propel forward - If thrown or dropped, move forward with a given force.
* Rotate forward - If thrown or dropped, rotate forward with a given force.
* Allow - Allows certain extra rights in the area
* Disallow - Disallows certain extra rights in the area
* Show board [name] - Opens a dialog with the board by that name.
* Show chat keyboard - Let's you enter a text chat line.
* Show name tags - Shows the name tags again for a while.
* Show video controls - Shows the controls dialog for the closest nearby video screen.
* Show web [url] - Loads URL in a browser on the nearest web screen.
* Do creation part - Lets you create tools to change a thing part in Change Things mode
* Do all creation parts - Lets you create tools to change thing parts in Change Things mode
* Show board [name] - Opens the board with the specified name
* Go to inventory page [number] - If the inventory is open, moves to the specified page [1-100]
* Add crumbles - Shows crumbles (small particles) falling off the part.
* Add crumbles for all parts - Shows crumbles falling off all parts in the object.
* Type "[Text]" - Adds this text line (written in quotes) to a part script.
* Set speed - 1 or 3 numbers, like 200.5, to set the speed of emitted thrown things.
* Set snap angles to [number] - e.g. 45? (Normal: 90. Soft: 22.5). Must be on body. Resets on area change.
* Set snap angles to default - Unsets the previously set angles and uses the current default snap settings.
* Set camera position to - Set the desktop camera position
* Set camera following to - Set the desktop camera follow smoothing
* Set gravity to [x y z] - Sets the area gravity. Default is 0 -9.81 0. Each value can range from -1000 to 1000.
* Set gravity to default - Sets the area gravity to the default 0 -9.81 0.
* Set light intensity [number] - Sets the strength of the applied light materials from 0-100 (Default: 12.0).
* Set light range [number] - Sets the distance applied light materials shine from 0-10000 meter.
* Set light cone size [number] - Sets the cone size for the spotlights from 0-170.
* Set voice - Sets the voice properties for the "Say" command.
* Add speed [number] - Use a number to add a force to velocity (-1000 to 1000)
* Multiply speed [number] - Use a number to multiply the speed by (Maximum 1000)
* Change head to [thing] - Attaches a head, which may attach a body. Must be placed or attached.
* Change heads to [thing] - Same as "Change head" but for everyone around.
* Resize nearby to [number] - Resizes people to given % (Needs to be placed)
* Stream to nearest - Becomes a camera and streams to the nearest video screen.
* Stream to [thing name] - Streams to the name of the thing which has a video screen.
* Stream to desktop - Streams to the desktop stream.
* Stream stop - Stops the stream.
* Say [speech] - Placeholders supported. "When starts then set voice ..." adjusts voice.
* Write [text] - Changes this parts text to this. Placeholders are supported.
* Project
* Show Line
* Trail start - Starts a trail left behind this part, using the part materials and colors.
* Trail start with [number] - Sets a trail duration of e.g. 10 seconds (Default is 15 seconds, Maximum is 30 seconds).
* Trail end - Ends the current trail.
* Reset area - Resets states, thing & area.\* variables, deletions and movable positions. (Needs to be placed)
* Reset persons - Resets person.\* variables of everyone currently here. (Needs to be placed)
* Reset position - Resets thing to its original placement position, e.g. for moveables.
* Reset rotation - Resets thing to its original placement rotation, e.g. for moveables.
* Turn on - Enables both collision and visibility for this part.
* Turn off - Disables both collision and visibility for this part.
* Turn visible - Turns the part visible.
* Turn invisible - Turns the part invisible.
* Turn collidable - Turns on physics collisions.
* Turn uncollidable - Turns off physics collisions (Unless "touch uncollidable as editor" is on or the inventory is showing).
* Turn thing - Relates to the whole thing.
* Turn sub-thing [optional name] - Relates to this parts included sub-things of this name or any name.