logo

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

Mitteilung

Icon
Error

Einloggen


Optionen
Ansicht
Gehe zum aktuellsten Beitrag Gehe zum letzten Ungelesenen
Offline MartinRJ Fayray  
#1 Geschrieben : Montag, 8. September 2014 14:18:18(UTC)
MartinRJ Fayray

Rang: Ehrenmitglied

Ansehen:

Mitglied seit: 05.09.2014(UTC)
Beiträge: 84
Germany
Wohnort: Tulln und Rostock

Dankte: 1 mal(e)
Das ist meine aktuelle Variante eines Multi-Page-Dialog- Skripts.
Die Aktion, die ausgeführt werden soll, wenn der User sich schließlich für einen der Buttons in dem Dialog entscheidet, steht ganz unten im Listener, und die Aktion ist in dem Beispiel:
Zitat:
llRegionSayTo(id, PUBLIC_CHANNEL, sTestMessage+message);

(das Skript informiert den User mit einer privaten Chatnachricht über seine Auswahl)

Die Buttons des Dialogs stehen in der Liste lDIALOG_OPTIONS, als Strings (Texte).

Code:

integer iSTART_PAGE = 1; //Dialog-Options
string sDIALOG_TEXT = "Bitte wählen Sie:";

string sTestMessage = "Sie wählten folgende Option: ";

//List with dialog-options.
list lDIALOG_OPTIONS = ["button 1","button 2","button 3","button 4","button 5","button 6","button 7","button 8","button 9","button 10","button 11","button 12","button 13","button 14","button 15","button 16","button 17","button 18","button 19","button 20","button 21","button 22","button 23","button 24","button 25","button 26","button 27","button 28","button 29","button 30"];

integer iListen; //Channel-params
integer iCHANNEL;

float fMagChannel = 10000.0;
float fMinChannel = 3.0;

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_Close = "Close dialog";
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, sC_Close, 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, sC_Close, 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;
    }
}

default
{
    state_entry()
    {
        iCHANNEL = (integer)(llFrand(fMagChannel)+fMinChannel);
        llListen(iCHANNEL, "", "", "");
    }
    touch_start(integer total_number)
    {
        fDIALOG(llDetectedKey(0), lDIALOG_OPTIONS, 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, lDIALOG_OPTIONS, iGetPage(message), sDIALOG_TEXT, iCHANNEL);
        }
        else
        {
            llRegionSayTo(id, PUBLIC_CHANNEL, sTestMessage+message);
        }
    }
}

Bearbeitet vom Moderator Freitag, 19. September 2014 09:47:44(UTC)  | Grund: Nicht angegeben

It is the mark of an educated mind to be able to entertain a thought without accepting it.

Wanna join the discussion?! Login to your forum account.Neue Registrierungen sind deaktiviert.

Offline MartinRJ Fayray  
#2 Geschrieben : Sonntag, 12. Oktober 2014 16:38:31(UTC)
MartinRJ Fayray

Rang: Ehrenmitglied

Ansehen:

Mitglied seit: 05.09.2014(UTC)
Beiträge: 84
Germany
Wohnort: Tulln und Rostock

Dankte: 1 mal(e)
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 );
        }
    }  
}
It is the mark of an educated mind to be able to entertain a thought without accepting it.
Rss Feed  Atom Feed
Benutzer, die gerade dieses Thema lesen
MozSpider-AhrefsBot 7.0, OceanSpiders 2.0
Das Forum wechseln  
Du kannst keine neue Themen in diesem Forum eröffnen.
Du kannst keine Antworten zu Themen in diesem Forum erstellen.
Du darfst deine Beiträge nicht löschen.
Du darfst deine Beiträge nicht editieren.
Du kannst keine Umfragen in diesem Forum erstellen.
Du kannst nicht an Umfragen teilnehmen.

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

Datenschutzrichtlinie
Haftungsausschluss
Impressum
Datenschutzerklärung
AGB, ToS
Kontakt