Object Scripting: Difference between revisions

From DeltaWiki
Jump to navigation Jump to search
(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>...")
 
(Redirected page to Object scripting)
Tag: New redirect
 
Line 1: Line 1:
[[Image:Object_properties.jpg|frame|Object Properties Dialog Box]]
#REDIRECT [[Object scripting]]
 
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 [[name|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 [http://en.wikipedia.org/wiki/Unicode 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
 
 
{| class="wikitable" style="width: 100%"
|+ '''Chart of valid HTML colors'''
! Preset
! Hex
! width=40px | Sample
! Preset
! Hex
! width=40px | Sample
! Preset
! Hex
! width=40px | Sample
! Preset
! Hex
! width=40px | Sample
|-
|aquamarine||70DB93||bgcolor=#70DB93|
|black||000000||bgcolor=#000000|
|blue||0000FF||bgcolor=#0000FF|
|brass||B5A642||bgcolor=#B5A642|
|-
|bronze||8C7853||bgcolor=#8C7853|
|brown||A62A2A||bgcolor=#A62A2A|
|copper||B87333||bgcolor=#B87333|
|cyan||00FFFF||bgcolor=#00FFFF|
|-
|darkgrey||00FFFF||bgcolor=#303030|
|forestgreen||238E23||bgcolor=#238E23|
|gold||CD7F32||bgcolor=#CD7F32|
|green||00FF00||bgcolor=#00FF00|
|-
|grey||707070||bgcolor=#707070|
|lightgrey||C0C0C0||bgcolor=#C0C0C0|
|magenta||FF00FF||bgcolor=#FF00FF|
|maroon||8E236B||bgcolor=#8E236B|
|-
|navyblue||23238E||bgcolor=#23238E|
|orange||FF7F00||bgcolor=#FF7F00|
|orangered||FF2400||bgcolor=#FF2400|
|orchid||DB70DB||bgcolor=#DB70DB|
|-
|pink||FF6EC7||bgcolor=#FF6EC7|
|red||FF0000||bgcolor=#FF0000|
|salmon||6F4242||bgcolor=#6F4242|
|scarlet||8C1717||bgcolor=#8C1717|
|-
|silver||E6E8FA||bgcolor=#E6E8FA|
|skyblue||3299CC||bgcolor=#3299CC|
|tan||DB9370||bgcolor=#DB9370|
|teal||007070||bgcolor=#007070|
|-
|turquoise||ADEAEA||bgcolor=#ADEAEA|
|violet||4F2F4F||bgcolor=#4F2F4F|
|white||FFFFFF||bgcolor=#FFFFFF|
|yellow||FFFF00||bgcolor=#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.
{| style="width: 100%" class="wikitable sortable"
|+ '''Object scripting command matrix'''
|-
! Category
! Command
! Description
! style="width: 100px" | Supports global?
! style="width: 100px" | Supports name?
|-
|Animation||'''[[Animate]]'''||Assigns an animation to an object||{{yes}}||{{yes}}{{footref}}
|-
|Animation||'''[[Astart]]'''||Starts an assigned animation||{{yes}}||{{yes}}{{footref}}
|-
|Animation||'''[[Astop]]'''||Stops an ongoing assigned animation||{{yes}}||{{yes}}{{footref}}
|-
|Animation||'''[[Frame]]'''||Sets the current frame of an animation||{{no}}||{{yes}}{{footref}}
|-
|Animation||'''[[Seq (building command)|Seq]]'''||Applies an avatar SEQ animation to an object||{{yes}}||{{yes}}
|-
|Audio||'''[[Midi]]'''||Plays a single midi note||{{yes}}||{{no}}
|-
|Audio||'''[[Noise]]'''||Plays a single sound effect at 100% volume, allowing overlap||{{no}}||{{no}}
|-
|Audio||'''[[Sound]]'''||Plays a background sound with position-sensitive volume and panning, allowing loop||{{yes}}||{{yes}}
|-
|Cosmetic||'''[[Alpharef]]'''||Sets alpha referencing setting for an object||{{yes}}||{{yes}}
|-
|Cosmetic||'''[[Color]]'''||Applies a flat non-maskable color to an object||{{no}}||{{yes}}
|-
|Cosmetic||'''[[Envi]]'''||Renders a scene to texture from an object's perspective||{{yes}}||{{yes}}
|-
|Cosmetic||'''[[Matfx]]'''||Applies a special texture effect to an object||{{yes}}||{{yes}}
|-
|Cosmetic||'''[[Opacity (command)|Opacity]]'''||Sets the opacity of an object||{{yes}}||{{yes}}
|-
|Cosmetic||'''[[Picture]]'''||Applies a local or remote image URL to an object with at least one surface tagged 200||{{yes}}||{{yes}}
|-
|Cosmetic||'''[[Sign]]'''||Renders text to an object with at least one surface tagged 100||{{yes}}||{{yes}}
|-
|Cosmetic||'''[[Shadow]]'''||Renders an object's shadow||{{yes}}||{{yes}}{{footref}}
|-
|Cosmetic||'''[[Texture]]'''||Applies a texture to an object||{{yes}}||{{yes}}
|-
|Interactivity||'''[[Examine]]'''||Allows an object to be rotated by dragging the mouse||{{no}}||{{no}}
|-
|Interactivity||'''[[Group]]'''||Spawns a non-editable AWG file from the [[object path]]||{{no}}||{{no}}
|-
|Interactivity||'''[[Link]]'''||Links the object to a nearby named '''[[mover]]'''||{{no}}||{{no}}
|-
|Interactivity||'''[[Lock]]'''||Restricts a trigger to certain citizens||{{no}}||{{no}}
|-
|Interactivity||'''[[Name]]'''||Assigns a name to an object for use with other commands||{{no}}||{{no}}
|-
|Interactivity||'''[[Say]]'''||Prints a given string or description to chat||{{no}}||{{no}}
|-
|Interactivity||'''[[Tag]]'''||Sets the enabled state of a nearby [[particle emitter]]||{{no}}||{{no}}
|-
|Interactivity||'''[[Timer]]'''||Creates or modifies a timer||{{yes}}||{{no}}
|-
|Lighting||'''[[Corona]]'''||Emits a sprite corona of fixed size||{{no}}||{{yes}}
|-
|Lighting||'''[[Light]]'''||Emits light from an object||{{no}}||{{yes}}
|-
|Physics||'''[[Addforce]]'''||Adds a force to a physical object||{{no}}||{{yes}}
|-
|Physics||'''[[Addtorque]]'''||Adds momentum to a physical object||{{no}}||{{yes}}
|-
|Physics||'''[[Ballsocket]]'''||Applies a ball and socket joint to a physical object||{{no}}||{{no}}
|-
|Physics||'''[[Collider]]'''||Makes an object physically interactive||{{yes}}||{{yes}}
|-
|Physics||'''[[Colltag]]'''||Assigns a collision tag (identifier) to a physical object||{{no}}||{{no}}
|-
|Physics||'''[[Hinge]]'''||Applies a hinge joint to a physical object||{{no}}||{{no}}
|-
|Physics||'''[[Reset]]'''||Resets all physical objects in the visible vicinity||{{yes}}||{{yes}}
|-
|Physics||'''[[Velocity]]'''||Applies a speed vector to a physical object||{{no}}||{{no}}
|-
|Transforms||'''[[Move]]'''||Moves an object||{{yes}}||{{yes}}
|-
|Transforms||'''[[Rotate]]'''||Spins an object||{{yes}}||{{yes}}
|-
|Transforms||'''[[Scale]]'''||Scales an object||{{yes}}||{{yes}}
|-
|Transforms||'''[[Shear]]'''||Shears an object, preserving its volume||{{yes}}||{{yes}}
|-
|Transforms||'''[[Skew]]'''||Skews an object||{{yes}}||{{yes}}
|-
|Transforms||'''[[Solid]]'''||Determines if an object is solid to avatars||{{yes}}||{{yes}}{{footref}}
|-
|Transforms||'''[[Visible]]'''||Determines if an object is visible||{{yes}}||{{yes}}{{footref}}
|-
|User||'''[[Camera]]'''||Switches the user's viewpoint||{{yes}}||{{no}}
|-
|User||'''[[Teleport]]'''||Teleports the user to a specified location||{{no}}||{{no}}
|-
|User||'''[[Teleportx]]'''||Teleports the user to a specified location in the same world without appending to history||{{no}}||{{no}}
|-
|User||'''[[Warp]]'''||Moves the user to a specified location||{{no}}||{{no}}
|-
|Web||'''[[Media]]'''||Allows playback and interaction of Windows Media Player compatiable content||{{no}}||{{yes}}
|-
|Web||'''[[URL]]'''||Opens a URL in browser||{{no}}||{{no}}
|-
|Web||'''[[Web]]'''||Renders a URL to an interactive texture on an object||{{yes}}||{{yes}}
|-
|Zone||'''[[Skybox]]'''||Sets an alternative skybox while within a zone||{{no}}||{{no}}
|}
* {{footnote|1|Uses the legacy name flag format, e.g. <code>create visible [name] on</code> instead of <code>create move 10 name{{=}}[name]</code>}}
 
[[Category:Building| ]]
[[Category:Lists]]

Latest revision as of 01:37, 5 May 2023

Redirect to: