TextureSwitcher

De DigiWiki.

Version du 22 mars 2012 à 14:33 par Djphil (discuter | contributions)
(diff) ← Version précédente | Voir la version courante (diff) | Version suivante → (diff)

I wrote this code for a client who needed a last minute gift. She asked i post it so here it is :-) By setting a value to time you can make it shift images every time period.

if you want the image to change by touch remove the comments from the touch_start event. "//"

// TextureSwitcher Writen by Strife Onizuka
 
float time = 30; //give me a value if you want time based shifting otherwise set to zero
 
integer total;
integer counter;
 
next()
{
    string name = llGetInventoryName(INVENTORY_TEXTURE,counter);
    if(name == "")
    {
        total = llGetInventoryNumber(INVENTORY_TEXTURE);
        counter = 0;
        if(total < 1)
            return;
        else
            name = llGetInventoryName(INVENTORY_TEXTURE,counter);
    }
    else if(counter + 1 >= total)
        total = llGetInventoryNumber(INVENTORY_TEXTURE);
    llSetTexture(name ,ALL_SIDES);
    if(total)
        counter = (counter + 1) % total;
}
 
default
{
    state_entry()
    {
        total = llGetInventoryNumber(INVENTORY_TEXTURE);
        next();
        llSetTimerEvent(time);
    }
//    touch_start(integer a)
//    {
//        llSetTimerEvent(0);
//        next();
//        llSetTimerEvent(time);
//    }
    timer()
    {
        next();
    }
}
Outils personnels
donate
Google Ads