Difference between revisions of "User:DoteDote Edison"

From Second Life Wiki
Jump to navigation Jump to search
m
 
(14 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{LSL Header}}
{{LSL Header}}
Thinker | Trouble-shooter | Problem-Solver
----


 
{{visl
 
|name=DoteDote Edison
Not a Wiki pro, so using this page to figure out how to format properly.
|Greeters=
 
|Helpers=*
====Example Scripts for the Examples page once it's formatted:====
|Instructors=
=====Toggle On/Off via State=====
|Mentors=*
An example script showing how [[state]] changes can be a useful method to switch between two script modes, in this case, On or Off.  When the script first runs, it begins in the '''default''' state and the [[state_entry]] event is executed.  When a user interacts with the object by touch, the script switches to the '''on''' state.  The '''on''' state executes its state_entry event, then waits for a user touch to trigger a state change back to the '''default''' state.
|LSL=
|i18n=
<pre><lsl>
|l10n=
// Toggle On-Off via State
|SL4B=
 
|}}
default {
{{skills
    state_entry() {
|Builder=*
// run this code when entering the default state
|Scripter=*
// displays red "OFF" as floating text above the prim
|}}
llSetText("OFF", <1,0,0>, 1.0);
}
    touch_start(integer num_detected) {
// when touched, switch to state named 'on'
state on;
}
}
 
state on {
state_entry() {
// run this code when entering state 'on'
// displays green "ON" as floating text above the prim
llSetText("ON", <0,1,0>, 1.0);
}
touch_start(integer num_detected) {
// when touched, switch to the default state
state default;
}
}
</lsl></pre>

Latest revision as of 20:35, 5 October 2008

Thinker | Trouble-shooter | Problem-Solver