LsSetWindlightScene
From OpenSimulator
(Difference between revisions)
(changed parameter work to link to Parameters page) |
|||
(7 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
= lsSetWindlightScene = | = lsSetWindlightScene = | ||
== Function == | == Function == | ||
− | + | '''integer''' lsSetWindlightScene('''list''' rules); | |
− | Set a list of [ | + | Set a list of [http://wiki.secondlife.com/wiki/WindLight_settings Windlight settings] in the scene to new values |
− | * | + | * '''list''' rules - a list containing pairs of [[LightShare Parameters]] and values to set |
== Caveats == | == Caveats == | ||
− | The list used by this function cannot be passed directly from [[lsGetWindlightScene]] without triggering C# exceptions from the | + | The list used by this function cannot be passed directly from [[lsGetWindlightScene]] without triggering C# exceptions from the Simulator. |
− | [[LightShare]] must be enabled in the | + | [[LightShare]] must be enabled in the Simulator. |
This script function is restricted to the region owner only. | This script function is restricted to the region owner only. | ||
== Examples == | == Examples == | ||
− | + | <source lang="lsl"> | |
− | + | // | |
− | + | // lsSetWindlightScene Script Exemple | |
− | + | // Author: djphil | |
− | + | // | |
− | + | ||
− | + | integer switch; // Variable to switch between colors | |
− | + | ||
− | + | default | |
− | + | { | |
+ | // Event handler triggered when the script is initialized | ||
+ | state_entry() | ||
+ | { | ||
+ | // Send a message to public channel informing users to touch to see usage | ||
+ | llSay(PUBLIC_CHANNEL, "Touch to see lsSetWindlightScene usage."); | ||
+ | // Set text above the object to indicate the script's function | ||
+ | llSetText("lsSetWindlightScene", <1.0, 1.0, 1.0>, 1.0); | ||
+ | } | ||
+ | |||
+ | // Event handler triggered when the object is touched | ||
+ | touch_start(integer number) | ||
+ | { | ||
+ | vector color = <4.0, 38.0, 64.0>; // Default color | ||
+ | |||
+ | // Switch between default color and random color | ||
+ | if (switch = !switch) | ||
+ | { | ||
+ | color = <llFrand(255.0), llFrand(255.0), llFrand(255.0)>; // Generate a random color | ||
+ | } | ||
+ | |||
+ | // Define settings list with water color setting | ||
+ | list settings = [WL_WATER_COLOR, color]; | ||
+ | |||
+ | // Call lsSetWindlightScene function to set the Windlight scene with the new settings | ||
+ | integer result = lsSetWindlightScene(settings); | ||
+ | |||
+ | // Check if the settings were applied successfully | ||
+ | if (result == TRUE) | ||
+ | { | ||
+ | // Notify users about the success and display the current water color | ||
+ | llSay(PUBLIC_CHANNEL, "The Windlight Scene was changed with success."); | ||
+ | llSay(PUBLIC_CHANNEL, "The current water color is: " + (string)color); | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | // Notify users about the failure to change the Windlight Scene | ||
+ | llSay(PUBLIC_CHANNEL, "The Windlight Scene was changed without success."); | ||
+ | } | ||
} | } | ||
− | + | } | |
+ | </source> | ||
== Notes == | == Notes == | ||
Line 38: | Line 77: | ||
== See Also == | == See Also == | ||
=== Functions === | === Functions === | ||
− | *[[lsGetWindlightScene]] | + | * [[lsGetWindlightScene]] |
− | *[[lsSetWindlightSceneTargeted]] | + | * [[lsSetWindlightScene]] |
+ | * [[lsSetWindlightSceneTargeted]] | ||
+ | * [[lsClearWindlightScene]] | ||
=== Articles === | === Articles === | ||
− | *[[LightShare]] | + | * [[LightShare]] |
− | *[[LightShare Parameters]] | + | * [[LightShare Parameters]] |
== Deep Notes == | == Deep Notes == | ||
=== All Issues === | === All Issues === | ||
− | *http://opensimulator.org/mantis/search.php?project_id=1&search=lsSetWindlightScene&hide_status_id=-2 | + | * http://opensimulator.org/mantis/search.php?project_id=1&search=lsSetWindlightScene&hide_status_id=-2 |
+ | |||
+ | [[Category:Scripting]] |
Latest revision as of 02:00, 5 March 2024
Contents |
[edit] lsSetWindlightScene
[edit] Function
integer lsSetWindlightScene(list rules);
Set a list of Windlight settings in the scene to new values
- list rules - a list containing pairs of LightShare Parameters and values to set
[edit] Caveats
The list used by this function cannot be passed directly from lsGetWindlightScene without triggering C# exceptions from the Simulator.
LightShare must be enabled in the Simulator.
This script function is restricted to the region owner only.
[edit] Examples
// // lsSetWindlightScene Script Exemple // Author: djphil // integer switch; // Variable to switch between colors default { // Event handler triggered when the script is initialized state_entry() { // Send a message to public channel informing users to touch to see usage llSay(PUBLIC_CHANNEL, "Touch to see lsSetWindlightScene usage."); // Set text above the object to indicate the script's function llSetText("lsSetWindlightScene", <1.0, 1.0, 1.0>, 1.0); } // Event handler triggered when the object is touched touch_start(integer number) { vector color = <4.0, 38.0, 64.0>; // Default color // Switch between default color and random color if (switch = !switch) { color = <llFrand(255.0), llFrand(255.0), llFrand(255.0)>; // Generate a random color } // Define settings list with water color setting list settings = [WL_WATER_COLOR, color]; // Call lsSetWindlightScene function to set the Windlight scene with the new settings integer result = lsSetWindlightScene(settings); // Check if the settings were applied successfully if (result == TRUE) { // Notify users about the success and display the current water color llSay(PUBLIC_CHANNEL, "The Windlight Scene was changed with success."); llSay(PUBLIC_CHANNEL, "The current water color is: " + (string)color); } else { // Notify users about the failure to change the Windlight Scene llSay(PUBLIC_CHANNEL, "The Windlight Scene was changed without success."); } } }
[edit] Notes
Rules contain pairs of data in the form of the parameter followed by the value to set.
Setting new parameters with this function commits the new changes to the regionwindlight database table immediately.
Excessive use of this function can cause unnecessary database requests.
Use lsSetWindlightSceneTargeted if you wish to avoid database loading with this function.
[edit] See Also
[edit] Functions
- lsGetWindlightScene
- lsSetWindlightScene
- lsSetWindlightSceneTargeted
- lsClearWindlightScene