Jump to content

Roswell Grayman

Resident
  • Posts

    5
  • Joined

  • Last visited

Posts posted by Roswell Grayman

  1. Basically, it's easy. With integer in LSL, you may operate 32 distinct bits (as the integer is stored in 4 bytes). To set a bit, pick its position (starting from right to left, 0 to 31) and power 2 to the position, then apply the 'bitwise or' operator, for example:

    integer b = 0;
    b = b | 0x8; // 0x8 (8 decimal) is 2 power 3, hence we're setting here the 4th bit (remember, the position is counted from 0)
    b = b | 0x40; // 0x40 (64 decimal) is 2 power 6, so the set bit is 7th.

    To check if a bit is set, simply apply the 'bitwise and':

    integer b = 0x48;
    if ( b & 0x20 == 0x20 ) { } // false (think why :)
    if ( b & 0x8 == 0x8 ) { } // true
    if ( b & 0x40 == 0x40 ) { } // true aswell

    Good luck!

  2. Here's the very basic example. Upon start, it renders the prim invisible, then cycles through every face and switches its visibility.

     

    integer last = 0;integer total = 0;float delay = 1.0; // The delay between cycle steps, in secondsdefault {    on_rez( integer param ) {        llResetScript();    }    state_entry() {        total = llGetNumberOfSides();        integer i;        for ( i = 0 ; i < total ; i ++ ) {            llSetAlpha( 0.0, i );        }        llSetTimerEvent( delay );    }    timer() {        llSetAlpha( 0.0, last );        last ++;        if ( last > total - 1 ) {            last = 0;        }        llSetAlpha( 1.0, last );    }}

     

×
×
  • Create New...