Difference between revisions of "Zigzag Sequence"

From Second Life Wiki
Jump to navigation Jump to search
Line 2: Line 2:


While scripting my checkers board, it came around the point where rezzing the pieces was required. As many of you know (or should) a checkers board is somewhat like quadrant 1 of a coordinate plane, that being said the coordinates must alternate in a sequence (i.e. (0,0), (1,1), (2,0), (3,1)...). Instead of using a static list and inputting 0s and 1s (like you would do with an array or something) I just incorporated a bit of Trig.
While scripting my checkers board, it came around the point where rezzing the pieces was required. As many of you know (or should) a checkers board is somewhat like quadrant 1 of a coordinate plane, that being said the coordinates must alternate in a sequence (i.e. (0,0), (1,1), (2,0), (3,1)...). Instead of using a static list and inputting 0s and 1s (like you would do with an array or something) I just incorporated a bit of Trig.
== The Script ==
This is just a simple for loop with text so you get the idea.
<lsl>
Loop(integer max) {
    list sequence;
    integer x;
    for(x = 0;x <= max; ++x) {
        integer y = llCeil(llSin((x+1) * PI));
        sequence += llList2CSV([x,y]);
        sequence += "\n";
        llSetText((string) sequence, <1,1,1>, 1);
    }
}
default
{
    state_entry() {
        Loop(8);
    }
}
</lsl>


== The Script ==  
== The Script ==  

Revision as of 12:27, 3 September 2011

Origin

While scripting my checkers board, it came around the point where rezzing the pieces was required. As many of you know (or should) a checkers board is somewhat like quadrant 1 of a coordinate plane, that being said the coordinates must alternate in a sequence (i.e. (0,0), (1,1), (2,0), (3,1)...). Instead of using a static list and inputting 0s and 1s (like you would do with an array or something) I just incorporated a bit of Trig.

The Script

This is just a simple for loop with text so you get the idea.

<lsl> Loop(integer max) {

   list sequence;
   integer x;
   for(x = 0;x <= max; ++x) {
       integer y = llCeil(llSin((x+1) * PI));
       sequence += llList2CSV([x,y]);
       sequence += "\n";
       llSetText((string) sequence, <1,1,1>, 1);
   }

} default {

   state_entry() {
       Loop(8);
   }

} </lsl>

The Script

This is just a simple for loop with text so you get the idea.

<lsl> Loop(integer max) {

   list sequence;
   integer x;
   for(x = 0;x <= max; ++x) {
       integer y = llCeil(llSin((x+1) * PI));
       sequence += llList2CSV([x,y]);
       sequence += "\n";
       llSetText((string) sequence, <1,1,1>, 1);
   }

} default {

   state_entry() {
       Loop(8);
   }

} </lsl>

The Script

This is just a simple for loop with text so you get the idea.

Loop(integer max) {

   list sequence;
   integer x;
   for(x = 0;x <= max; ++x) {
       integer y = llCeil(llSin((x+1) * PI));
       sequence += llList2CSV([x,y]);
       sequence += "\n";
       llSetText((string) sequence, <1,1,1>, 1);
   }

} default {

   state_entry() {
       Loop(8);
   }

}