Jump to content

Boopadoopdoop

Resident
  • Posts

    8
  • Joined

  • Last visited

Posts posted by Boopadoopdoop

  1. integer counter = 10;  // chosen amount of living time in seconds.
    float CountDownSpeed = 1.0; // how fast to count down.
    DoText(string output)
    {
        llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_TEXT, output, <1.0,1.0,1.0>, 1.0]); // set text based on output
    }
    DoPayload()
    {
        llSleep(CountDownSpeed); // lol lazy sleep to keep the timing correct after it reaches zero
        DoText("KABOOM!!!!! lolzolz"); // send payload text to output.
        llResetScript(); //doing this instead of llDie for testing. lol
        //llDie();   
    }
    default
    {
        state_entry() //Can remove state entry if not using llResetScript, just here for example.
        {
            llSleep(CountDownSpeed); // lol lazy sleep
            DoText(""); // blank out text   
        }
        touch_start(integer total_number)
        {
            llSetTimerEvent(CountDownSpeed);  // setting timer to the interval of a second
        }
        timer()
        {
            DoText((string)counter-- + " seconds"); // send count text to output.
        if(counter < 0)
        {
            DoPayload(); // do payload.
        }
        }
    }

  2. Friend helped me do this, but I can't for the life of me figure out how to sort the scores, how I need it to work, is anyone with a higher number score be sorted to the top of the list, I also need to script in a limit of 5 scores to be shown at once [tho keeping that limit changeable would be nice too]

     

    Quote

    //format is [User UUID, score, User UUID, score, ...]
    list scores;

    add_Key_and_Score(string user)
    {
        //find their index in the list
        //it is important that if we put STRINGS in the list we search for STRINGS
        //if you put a KEY in your list instead of a STRING, the STRING search won't find it
        //this is why the function takes an input of string as the argument
        
        integer find_in_list = llListFindList(scores,[user]);
        
        //if they are in the list, update their score
        if( ~ find_in_list )
        {
            //extract old score
            integer score = llList2Integer(scores, find_in_list + 1);
            
            //update it
            score += 1;
            
            //replace the old score with the new one in the list (using the same index)
            scores = llListReplaceList( scores, [score], find_in_list + 1, find_in_list + 1 );
        }
        
        //if they are not in the list, add them to it
        else
        {
            scores += [user, 1];
        }
    }
    display_score()
    {
        //iterate over the scores list and generate ssome formatted output
        list output;
        integer x;
        integer n = llGetListLength(scores);
        for(x=0;x<n;x+=2)
        {
            string name = llGetDisplayName(llList2String(scores,x));
            if( name == "" )
            name = "NOT IN REGION";
            
            string score = llList2String(scores,x+1);
            
            string entry = name + " : [" + score + "]";
            output += entry;
        }
        llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_TEXT,llDumpList2String(output,"\n"),<llFrand(1),llFrand(1),llFrand(1)>,1]);
    }

    default
    {
        touch_start(integer n)
        {
            while(~--n) { add_Key_and_Score(llDetectedKey(n)); }
            display_score();
        }
    }

     

    I tried using llListSort, but I'm either using it wrong, or am not sure how to implement it correctly.

     

    Any pointers would be appreciated!

  3. 29 minutes ago, Wulfie Reanimator said:

    There are no syntax errors in my code besides the "[ ... ]"

    I did not write code that you can just copypaste into your script. I showed you an example of how to use llListFindList to get an index from one list and use it in another. Now it's your turn to read the wiki page I linked, and teach yourself how to use that function.

    is already working, you example help, and i did not fully copy paste, just copied that one line for lazy reasons. lol thanx alot for help, is very nice!

    • Like 2
  4. 10 minutes ago, Love Zhaoying said:

    The “[...]” is for example only, you need to put a list of keys to replace the “.. “.

    was not the issue, did not see they change "textures" list to "uuids", so when copied over it was confusing what happen, is use diff viewer and it not jump to where script is wrong like firestorm do lol

  5. 44 minutes ago, Wulfie Reanimator said:

    You can use llListFindList on the list with names, to get that name's index. Then, you can use that index to access the UUID in the other list, assuming both lists are in the same order.

    
    list names = ["red", "blue", "green"];
    list uuids = [ ... ];
    
    default
    {
        listen(integer channel, string name, key id, string message)
        {
            integer index = llListFindList(names, [message]);
            key uuid;
            if (index != -1)
            {
                uuid = llList2Key(uuids, index);
            }
        }
    }

     

    figured it out, sorry bout that, haha, and thanx much!

    • Like 1
  6. So what is trying do, is trying to get the names from a dialog menu to mach with uuid's in a list, and no i don't want to have the textures inside the inventory, I want to hard code them inside.

    this is not the script is working on, is other script similar to figure this out, then can apply fix to actual script am working on.

    Is script that used to get textures from inventory, but want to hard code inside.

    [sorry English is bad]

     

    list textures = [
    "63305784-1523-1ddc-b301-8a1a3d6f7d09",
    "a628d431-2b18-ef75-826f-719a37b3a2de",
    "8dcd4a48-2d37-4909-9f78-f7a9eb4ef903"
    ];
    
    list names = [
    "blue",
    "pink",
    "HIDE"
    ];
    
    integer side = ALL_SIDES;
    integer link = 2;
    list texture_list;
    list texture_list2;
    key user = NULL_KEY;
    integer chan = -54;
    composelist()
    {
        integer currenttexture = 0;
        integer totaltextures = llGetListLength(textures);
        
        if(totaltextures > 0 & totaltextures <= 12)
        {
            texture_list = [];
            do
            {
                texture_list = texture_list + llList2String(names, currenttexture);
                currenttexture++;
            }
            while (currenttexture > 0 & currenttexture < totaltextures);
        }
        
        if(totaltextures > 12 & totaltextures <= 22)
        {
            texture_list = ["Next Page"];
            do
            {
                texture_list = texture_list + llList2String(names, currenttexture);
                currenttexture++;
            }
            while (currenttexture > 0 & currenttexture < 11);
            
            texture_list2 = ["Last Page"];
            do
            {
                texture_list2 = texture_list2 + llList2String(names, currenttexture);
                currenttexture++;
            }
            while (currenttexture >= 11 & currenttexture < totaltextures);
        }
        
        if(totaltextures > 22)
        {
            llWhisper(0, "Sorry, I can hold 22 textures.");
        }
        if(totaltextures == 0)
        {
            llWhisper(0, "No textures, please add some.");
        }
    }
    
    integer menu_handler;
    integer menu_channel;
    menu(key user,string title,list texture_list)
    {
        menu_channel = (integer)(llFrand(99999.0) * -1);
        menu_handler = llListen(menu_channel,"","","");
        llDialog(user,title,texture_list,menu_channel);
        llSetTimerEvent(30.0);
    }
    
    default
    {
        state_entry()
        {
            llListen(chan, "", llGetOwner(), "");
            composelist();
        }
    
        touch_start(integer total_number)
        {
            if (llDetectedKey(0) == llGetOwner()) {
            user = llGetOwner();
            menu(user,"nnPlease select one below.",texture_list);
        }
    }    
        listen(integer channel,string name,key id,string message)
        {
            if (channel == menu_channel)
            {
                llSetTimerEvent(0.0);
                llListenRemove(menu_handler);
                if(message == "Next Page")
                {
                    menu(user,"Please select one below.",texture_list2);
                }
                else if(message == "Last Page")
                {
                    menu(user,"Please select one below.",texture_list);
                }
                else
                {
                  /*somehow get dialog menu selection to identify UUIDs in same order as order of names list HERE*/
    
                    if (message == "HIDE")
                    {
                    llSetLinkAlpha(link,0,ALL_SIDES);    
                    llSetLinkTexture(link,message, side); //still set transparent texture
                }else{
                    llSetLinkAlpha(link,1,ALL_SIDES);    
                    llSetLinkTexture(LINK_THIS,message, side);//set root prim texture first for preloading.
                    llSleep(4);//give time to load before switching texture
                    llSetLinkTexture(link,message, side);
                }
            }
        }
    }
        timer()
        {
            llSetTimerEvent(0.0);
            llListenRemove(menu_handler);
        }
        
        changed(integer change)
        {
            if (change & CHANGED_INVENTORY)
            {
                composelist();
            }
        }
    }

     

    also want remove the limit on the menu.... but likely remake that part on own time....

×
×
  • Create New...