logo

Willkommen Gast! Um alle Funktionen zu aktivieren müssen Sie sich Anmelden.Neue Registrierungen sind deaktiviert.

Mitteilung

Icon
Error

Einloggen


Beitrag melden
Geschrieben von: MartinRJ Fayray Offline Geschrieben Sonntag, 12. Oktober 2014 16:38:31(UTC)
Hier ist ein Texture-Change- Skript auf Basis dieses Multi-Page Dialogs:
Code:
    
string sDelete = "delete script";

string sDIALOG_TEXT = "Select one object below: ";

list MENU = [];
 
// opens menu channel and displays dialog
fDIALOG(key kUser, list lButtons, integer iPage, string sText, integer iChannel)
{ //Generate dialog
    llDialog(kUser, sText, makedialoglist(lButtons, iPage), iChannel);
}

string sC_Prev = "Previous(p. ";
string sC_Next = "Next(p. ";
string sC_NextPreviousEnd = ")";
string sC_FillerButton = " "; //empty button
string sC_FillerZero = "0";
integer iC_FreeButtons = 9;
integer iC_Interface_At_Top = TRUE; //TRUE= prev/top/next-buttons are above the other buttons. FALSE= they are below.
integer iC_Buttonrow_Length = 3; //buttons per row in a dialog

list makedialoglist(list lItems, integer iPage_To_Display)
{ //Create dialog-button-list for a certain page.
    list lInterfacebuttons;
    integer iPrevPage;
    integer iNextPage;
    integer iListLength;
    integer iFree;
    integer iCounter;
    string sPrev = sC_Prev;
    string sNext = sC_Next;
    float fLength = (float)llGetListLength(lItems);
    integer iPages = llCeil(fLength/iC_FreeButtons);
    if (iPages == 0)
    { //error
        return [sC_Prev + sC_FillerZero + sC_NextPreviousEnd, sDelete, sC_Next + sC_FillerZero + sC_NextPreviousEnd];
    }
    if (iPages == 1)
    {
        iPrevPage = 1;
        iNextPage = 1;
    }
    else if (iPage_To_Display == iPages)
    {
        iPrevPage = iPage_To_Display-1;
        iNextPage = 1;
    }
    else if (iPage_To_Display == 1)
    {
        iPrevPage = iPages;
        iNextPage = iPage_To_Display+1;
    }
    else
    {
        iPrevPage = iPage_To_Display-1;
        iNextPage = iPage_To_Display+1;
    }
    sPrev+=(string)iPrevPage+sC_NextPreviousEnd;
    sNext+=(string)iNextPage+sC_NextPreviousEnd;
    lItems = llList2List(lItems,iC_FreeButtons*(iPage_To_Display-1),(iC_FreeButtons*(iPage_To_Display-1))+iC_FreeButtons-1);
    lInterfacebuttons = [sPrev, sDelete, sNext];
    iListLength = llGetListLength(lItems);
    //Calculate how many buttons need to be added as 'filler'.
    iFree = iC_Buttonrow_Length-(iListLength % iC_Buttonrow_Length);
    if (iFree == iC_Buttonrow_Length)
    {
        iFree = 0;
    }
    if (iC_Interface_At_Top)
    { //prev/top/next-buttons above of the list
        for (iCounter = 0; iCounter < iFree; iCounter++)
        {
            lItems += [sC_FillerButton];
        }
        return lItems + lInterfacebuttons;
    }
    else
    { //prev/top/next-buttons below the list
        for (iCounter = 0; iCounter < iFree; iCounter++)
        {
            lItems = [sC_FillerButton] + lItems;
        }
        return lInterfacebuttons + lItems;
    }
}
integer iGetPage(string sMsg)
{ //Get page number.
    string sTemp;
    if (llGetSubString(sMsg, 0, llStringLength(sC_Prev)-1) == sC_Prev)
    { //previous
        sTemp = llGetSubString(sMsg, llStringLength(sC_Prev), llStringLength(sMsg)-llStringLength(sC_NextPreviousEnd));
        return (integer)sTemp;
    }
    else if (llGetSubString(sMsg, 0, llStringLength(sC_Next)-1) == sC_Next)
    { //next
        sTemp = llGetSubString(sMsg, llStringLength(sC_Next), llStringLength(sMsg)-llStringLength(sC_NextPreviousEnd));
        return (integer)sTemp;
    }
    else
    { //error
        return 0;
    }
}

integer iMaxLength = 24; //max length of a button label

integer iListen; //Channel-params
integer iCHANNEL;

float fMagChannel = 10000.0;
float fMinChannel = 3.0;

integer iSTART_PAGE = 1; //Dialog-Options

load()
{ //load menu-items
    integer i;
    for (i = 0; i < llGetInventoryNumber(INVENTORY_TEXTURE); i++)
    {
        if (llStringLength(llGetInventoryName(INVENTORY_TEXTURE, i)) <= iMaxLength)
        {
            MENU += llGetInventoryName(INVENTORY_TEXTURE, i);
        }
    }
}
default
{
    on_rez(integer num)
    {
        // reset scripts on rez
        llResetScript();
    }
    state_entry()
    {
        iCHANNEL = (integer)(llFrand(fMagChannel)+fMinChannel);
        llListen(iCHANNEL, "", "", "");
        load();
    }
    changed(integer change)
    {
        MENU = [];
        if (change & CHANGED_INVENTORY)
        {
            load();
        }
    }
 
    touch_start(integer total_number)
    {
        // display the dialog 
        fDIALOG(llDetectedKey(0), MENU, iSTART_PAGE, sDIALOG_TEXT, iCHANNEL);
    }
 
    listen(integer channel, string name, key id, string message) 
    {
        if (iGetPage(message) != 0)
        { //Prev- or Next-button clicked
            fDIALOG(id, MENU, iGetPage(message), sDIALOG_TEXT, iCHANNEL);
        }
        else if (message == sDelete)
        {
                llRemoveInventory(llGetScriptName()); //delete script             
        }
        else
        {
            // display the texture from menu selection
            llSetLinkTexture( LINK_SET, message, ALL_SIDES );
        }
    }  
}
Geben Sie den Meldetext hier ein.
Fett Kursiv Unterstrichen   Hervorheben Zitat Sprachauswahl für Syntax Highlighting Bild einfügen Link einfügen   Unsortierte Liste Sortierte Liste   Linksbündig Zentriert Rechtsbündig   Herausrücken Einrücken   Weitere BBCodes
Schriftfarbe: Schriftgröße:
Melden Abbruch

Powered by YAF.NET | YAF.NET © 2003-2021, Yet Another Forum.NET
Diese Seite wurde in 0.027 Sekunden generiert.

Datenschutzrichtlinie
Haftungsausschluss
Impressum
Datenschutzerklärung
AGB, ToS
Kontakt