Object scripting

From DeltaWiki
Revision as of 00:15, 5 May 2023 by Xan (talk | contribs) (Created page with "frame|Object Properties Dialog Box Standard model-based objects support simple '''scripting''' with commands attached to event triggers. Generally, objects can support up to 256 characters (including whitespace) of action code and the majority of commands can be executed on other nearby objects using names. The basic syntax of action code is typically represented as: <Trigger 1> <Command 1> <Attribute 1>=<Integer>, <Command 1>...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Object Properties Dialog Box

Standard model-based objects support simple scripting with commands attached to event triggers. Generally, objects can support up to 256 characters (including whitespace) of action code and the majority of commands can be executed on other nearby objects using names.

The basic syntax of action code is typically represented as:

<Trigger 1> <Command 1> <Attribute 1>=<Integer>, <Command 1> <Attribute 1>="<String with spaces>" <Attribute 2>;
<Trigger 1> <Command 1>

Action code is successfully applied for any correctly written action and trigger. If there is a syntax error, the script will silently fail past the error. Any amount of whitespace is acceptable between any keyword or value, including newlines. This allows for cleaner action script, such as:

create
  color red,
  opacity 0.5;
activate
  color green

Triggers

A trigger defines a group of one or more commands which are executed depending on the event triggered. Trigger groups are separated by the semi-colon character (;). The last trigger group of a script does not require an ending semi-colon.

Trigger Executes commands when...
Create ...object comes into view.
Bump ...object is collided with by avatar.
Activate ...object is clicked.
Adone ...object's Animate animation is completed.
At ...a specified timer expires.
Collide ...two physics objects collide.
Enter Zone ...a specified zone is entered.
Exit Zone ...a specified zone is exited.
Sdone ...object's sound is finished playing.

Types

Commands accept parameters of varying types, such as strings and variables. Each type has limitations and syntactical variations.

Numbers

A number can be an integer or a floating point number with a precision of up to three decimal places.

create move 10 0.6 .455

Boolean

A boolean is a true or false value, however both have different aliases. To set a boolean attribute or value to true, the following will work:

create alpharef yes
create solid true
create visible on

To set a boolean attribute or value to false, the following will work:

create alpharef no
create solid false
create visible off

To save cell space, it is conventional to use on for true and no for false.

String

A string is a piece of unicode text of any length the 256 action code limit allows. The string can be a single word without double quotes.

create sign こんにちは!

Strings with whitespace (such as spaces, tabs or newlines) must begin with double quotes.

create sign "i am a string with
  multiple lines", color red

A string does not need to be terminated with double quotes if there is no more code after the string.

create sign "i am a string

Color

A color is either a standard HTML color identifier or hexadecimal value.

create color red
create color ff0000
create color RRGGBB


Chart of valid HTML colors
Preset Hex Sample Preset Hex Sample Preset Hex Sample Preset Hex Sample
aquamarine 70DB93 black 000000 blue 0000FF brass B5A642
bronze 8C7853 brown A62A2A copper B87333 cyan 00FFFF
darkgrey 00FFFF forestgreen 238E23 gold CD7F32 green 00FF00
grey 707070 lightgrey C0C0C0 magenta FF00FF maroon 8E236B
navyblue 23238E orange FF7F00 orangered FF2400 orchid DB70DB
pink FF6EC7 red FF0000 salmon 6F4242 scarlet 8C1717
silver E6E8FA skyblue 3299CC tan DB9370 teal 007070
turquoise ADEAEA violet 4F2F4F white FFFFFF yellow FFFF00

Commands

An action defines an instruction for an object to undertake when its associated trigger is fired. Actions for the same trigger group are separated by commas (,). An action can have zero or more parameters; these parameters are separated by whitespace (e.g. a space or a newline). Actions with syntax errors or invalid parameters will silently fail.

Object scripting command matrix
Category Command Description Supports global? Supports name?
Animation Animate Assigns an animation to an object [1]
Animation Astart Starts an assigned animation [1]
Animation Astop Stops an ongoing assigned animation [1]
Animation Frame Sets the current frame of an animation [1]
Animation Seq Applies an avatar SEQ animation to an object
Audio Midi Plays a single midi note
Audio Noise Plays a single sound effect at 100% volume, allowing overlap
Audio Sound Plays a background sound with position-sensitive volume and panning, allowing loop
Cosmetic Alpharef Sets alpha referencing setting for an object
Cosmetic Color Applies a flat non-maskable color to an object
Cosmetic Envi Renders a scene to texture from an object's perspective
Cosmetic Matfx Applies a special texture effect to an object
Cosmetic Opacity Sets the opacity of an object
Cosmetic Picture Applies a local or remote image URL to an object with at least one surface tagged 200
Cosmetic Sign Renders text to an object with at least one surface tagged 100
Cosmetic Shadow Renders an object's shadow [1]
Cosmetic Texture Applies a texture to an object
Interactivity Examine Allows an object to be rotated by dragging the mouse
Interactivity Group Spawns a non-editable AWG file from the object path
Interactivity Link Links the object to a nearby named mover
Interactivity Lock Restricts a trigger to certain citizens
Interactivity Name Assigns a name to an object for use with other commands
Interactivity Say Prints a given string or description to chat
Interactivity Tag Sets the enabled state of a nearby particle emitter
Interactivity Timer Creates or modifies a timer
Lighting Corona Emits a sprite corona of fixed size
Lighting Light Emits light from an object
Physics Addforce Adds a force to a physical object
Physics Addtorque Adds momentum to a physical object
Physics Ballsocket Applies a ball and socket joint to a physical object
Physics Collider Makes an object physically interactive
Physics Colltag Assigns a collision tag (identifier) to a physical object
Physics Hinge Applies a hinge joint to a physical object
Physics Reset Resets all physical objects in the visible vicinity
Physics Velocity Applies a speed vector to a physical object
Transforms Move Moves an object
Transforms Rotate Spins an object
Transforms Scale Scales an object
Transforms Shear Shears an object, preserving its volume
Transforms Skew Skews an object
Transforms Solid Determines if an object is solid to avatars [1]
Transforms Visible Determines if an object is visible [1]
User Camera Switches the user's viewpoint
User Teleport Teleports the user to a specified location
User Teleportx Teleports the user to a specified location in the same world without appending to history
User Warp Moves the user to a specified location
Web Media Allows playback and interaction of Windows Media Player compatiable content
Web URL Opens a URL in browser
Web Web Renders a URL to an interactive texture on an object
Zone Skybox Sets an alternative skybox while within a zone
  • ^ Uses the legacy name flag format, e.g. create visible [name] on instead of create move 10 name=[name]