Difference between revisions of "User:Toady Nakamura/Touch Counting"

From Second Life Wiki
Jump to navigation Jump to search
m (start page)
 
m (fix <source lang="lsl2"> </source> error which was causing page to display incorrectly)
 
(2 intermediate revisions by the same user not shown)
Line 5: Line 5:
'''Count Up'''
'''Count Up'''


<lsl>
<source lang="lsl2">  
integer num = 0;  // sets initial value at zero, so first one will be one
integer num = 0;  // sets initial value at zero, so first one will be one


Line 19: Line 19:
}
}


</lsl>
</source>  


'''Count Down'''
'''Count Down'''


<lsl>
<source lang="lsl2">  
integer num = 100; // sets initial value to count down from   
integer num = 100; // sets initial value to count down from   


Line 38: Line 38:
}
}


</lsl>
</source>  


both of these by https://wiki.secondlife.com/wiki/User:Toady_Nakamura/Touch_Counting
Visit my LSL wiki page for my library of simple scripts !  [[User:Toady Nakamura|Toady Nakamura]]
 
 
[[User:Toady Nakamura|Toady Nakamura]] please visit my wiki page for my library of simple scripts !

Latest revision as of 18:36, 28 July 2015

Counting - also called incrementing - can be confusing.

Here are two sample scripts to show you how to count up and down !!

Count Up

 
integer num = 0;  // sets initial value at zero, so first one will be one

default
{
    touch_start(integer total_number)
    {
        num++;  // increment the value of *num* upwards  
 
        llSetText("The value of num is now " + (string)num + " \n 
                   Touch me to increment upwards", <1,1,1>,1); 
    }
}

Count Down

 
integer num = 100; // sets initial value to count down from  

default
{
    touch_start(integer total_number)
    {
        num--;   // increment the value of *num* downwards

        llSetText((string)num + " bottles of prims on the wall \n" + 
                  (string)num + " bottles of prims... \n 
                   Touch me to increment down", <1,1,1>,1); 
    }
}

Visit my LSL wiki page for my library of simple scripts ! Toady Nakamura