Jump to content

SwireD

Resident
  • Posts

    36
  • Joined

  • Last visited

Posts posted by SwireD

  1. 18 hours ago, Rolig Loon said:

    It depends on how your door is constructed, of course.  Consult the sticky thread at the top of this form about how to write door scripts to see what your options are.  Once you have that figured out, then it's just a matter of making the door do two 45 degree rotations, reverse, and do another two 45 degree rotations. Over and over again.

    If you start with @Innula Zenovka's simple script, for example, you can split her 90 degree rotation into two and get 

    
    integer intSwing =45;
    rotation rotSwing;
    vector vOffset;
    integer iTouch = 1;  //Start with the door fully open ( = 1 ) or fully closed ( = -1 )
    
    default{    
    
        state_entry()
        {
            rotSwing = llEuler2Rot(<0.0,0.0,(float)intSwing>*DEG_TO_RAD);  //45 degrees on the z axis       
            vector size = llGetScale();       
            vOffset = <(size.x*-0.5),(size.y*-0.5),0.0>;//open away from someone standing in front of face 2 -- that is, in front of the prim -- hinged on the left.    
        }    
    
        touch_start(integer total_number)
        {
            if ( iTouch == 1 || iTouch == -1)	// Reverse direction
            {
                rotSwing.s *=-1;
                iTouch = -iTouch;            
            }
            list l = llGetPrimitiveParams([PRIM_POS_LOCAL,PRIM_ROT_LOCAL]);
            vector v = llList2Vector(l,0);
            rotation r = llList2Rot(l,1);
            llSetPrimitiveParams([PRIM_POS_LOCAL,v+(vOffset-vOffset * rotSwing)*r,PRIM_ROT_LOCAL,rotSwing*r]);
            ++iTouch;	// Prepare for the next step
        }
    }

    If your door is cut or rotates around different axes or has other geometric constraints, you'll start with a different basic script.  The approach is the same, though.  Think of it as simply rotating the door twice, reversing, and doing it again.

    Thank you very much! It works absolutely perfectly!

  2. Hello! Trying to create a door script with a menu to open in three stages. open, half open and closed. How to do it better? What is responsible for the rotation of the object in this case? This is not for the home but photographic backgrounds.

  3. Hi! Works much better! Thank you all! I had to use different coords for each platform.

    default
    {
        state_entry()
        {
            llListen(10, "", "", "");
        }
    
        listen(integer chan, string name, key id, string msg)
        {
            if (msg == "stop")
            {
                llSetKeyframedMotion([], [KFM_COMMAND, KFM_CMD_PAUSE]);
            }
            else if (msg == "start")
            {
                llSetKeyframedMotion([], [KFM_COMMAND, KFM_CMD_PLAY]);
                llSetKeyframedMotion([ < 3.5, -1.5, 0 > , 3, < 1.5, -3.5, 0 > , 3, < -1.5, -3.5, 0 > , 3, < -3.5, -1.5, 0 > , 3, < -3.5, 1.5, 0 > , 3, < -1.5, 3.5, 0 > , 3, < 1.5, 3.5, 0 > , 3, < 3.5, 1.5, 0 > , 3], [KFM_DATA, KFM_TRANSLATION, KFM_MODE, KFM_LOOP]);
            }
        }
    }

     

    • Like 2
  4. 12 hours ago, Rolig Loon said:

    Study llSetKeyframedMotion.  There are several examples in the LSL wiki.

    Thank you very much! I managed to create such a script. works almost - after passing the entire circle, the object stops at one point for 3 seconds. How to avoid it? and also if I add on/off toggle then after stop/start the path breaks and the objects begin to move along a different trajectory. Is it possible to keep the path? and the only way to get all the platforms to rotate along one trajectory for me was possible only by placing all the platforms at one point and adding a llSleep() for each subsequent platform with magnification.

    default
    {
        state_entry()
        {
            llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_PHYSICS_SHAPE_TYPE, PRIM_PHYSICS_SHAPE_CONVEX]);
            llSetKeyframedMotion([<0,0,0>, 3, <1.5,3.5,0>, 3, <3.5,1.5,0>, 3, <3.5,-1.5,0>, 3, <1.5,-3.5,0>, 3, <-1.5,-3.5,0>, 3, <-3.5,-1.5,0>, 3, <-3.5,1.5,0>, 3, <-1.5,3.5,0>, 3 ], [KFM_DATA, KFM_TRANSLATION, KFM_MODE, KFM_LOOP]);
        }
    }

     

  5. Hello! a friend of mine asked me a puzzle. How to make the object rotate or move along a certain path (circle)? there will be several such objects (dancepads - one script for each pad...), but the main problem - they cannot be linked to anything! I read somewhere that it is possible to specify the coordinates and the object will move from point to point. how to do it and is there any other way? 

    As example - solar system.

  6. 19 hours ago, Fenix Eldritch said:

    llGetNumberOfPrims only returns the total number of prims in the linkset. That's not going to be very helpful here. For example, if you have ten prims in your linkset, that function will return the integer 10 every time. You were on the right track with using the KEY = llDetectedLinkNumber(0).

    Try taking your previous example and modifying the llSay to look like this:

    
    llSay(0, "linknumber " + (string) KEY + " pressed, and it's name is "+llGetLinkName(KEY));

    The above code (when placed inside a touch event) will tell you the linknumber and the name of the prim touched.

    Now my previous suggestion depends upon placing copies of the sound assets directly into the piano's inventory. This is because we can rename them to match their associated piano key names. The LSL functions that actually emit sounds allow you to specify a sound either by UUID, or by the name of the sound file (as long as it exists in the object's personal inventory). So the idea here is to make a given key and its associated sound have the same name. For example, find the prim with linknumber 2 and in the build tool, rename the child prim to "KEY2". Then, get the sound asset you want for that key, place it in the piano (wherever the script will reside) and rename the sound file there to be "KEY2" as well.

    By doing this, we can eliminate the need for all those IF checks. Instead of checking "if key 2 is pressed, play this uuid" we can instead simply say:

    
    llPlaysound(llGetLinkName(KEY),1.0);

    The trick here is that since the specific key and associated sound have the exact same name, we don't need to do any tests. We just feed the prim's name into the sound function directly.

    Try adding that to your previous example.

     

    Thank you so VERY MUCH! Now it is finally perfect!

    vector KEY_OFFSET_DN = < 0.1, 0.0, 0.0 > ;
    vector KEY_OFFSET_UP = < -0.1, 0.0, 0.0 > ;
    
    default {
        touch_end(integer total_number) {
            integer KEY = llDetectedLinkNumber(0);
    
            if (KEY == 23 || KEY == 22 || KEY == 21 || KEY == 20 || KEY == 19 || KEY == 18) {
                llPlaySound(llGetLinkName(KEY), 1.0);
    //            llSay(0, "linknumber " + (string) KEY + " pressed, and it's name is " + llGetLinkName(KEY));
                llSetLinkPrimitiveParamsFast(KEY, [PRIM_POS_LOCAL, llList2Vector(llGetLinkPrimitiveParams(KEY, [PRIM_POS_LOCAL]), 0) + KEY_OFFSET_UP]);
                llSleep(0.1);
                llSetLinkPrimitiveParamsFast(KEY, [PRIM_POS_LOCAL, llList2Vector(llGetLinkPrimitiveParams(KEY, [PRIM_POS_LOCAL]), 0) + KEY_OFFSET_DN]);
            }
        }
    }

     

  7. Oh i forgot quotes! ""

    But for some reason it says "Key1" for each key. And for non-key objects...

    integer i = llGetNumberOfPrims();

            if (llGetLinkName(i) == "KEY1")
            {
                llSay(0, "Key1");
            }
            if (llGetLinkName(i) == "KEY2")
            {
                llSay(0, "Key2");
            }
            if (llGetLinkName(i) == "KEY3")
            {
                llSay(0, "Key3");
            }
            if (llGetLinkName(i) == "KEY4")
            {
                llSay(0, "Key4");
            }
            if (llGetLinkName(i) == "KEY5")
            {
                llSay(0, "Key5");
            }
            if (llGetLinkName(i) == "KEY6")
            {
                llSay(0, "Key6");
            }

  8. 33 minutes ago, Fenix Eldritch said:

    Now that I think more about it, you're probably going to want to have each key produce a unique sound, so it would become important to actually distinguish one key from another - whether by linknumber or name.

    Building on your latest script, you could give each piano key a unique name and then make the associated sound file have a matching name. That way when you play it, you would supply the name of the currently clicked prim as the sound's name.
     

    From what I managed to learn from the wiki, this turned out, but for some reason it does not work. i renamed the key...

     

    vector KEY_OFFSET_DN = < 0.1, 0.0, 0.0 > ;
    vector KEY_OFFSET_UP = < -0.1, 0.0, 0.0 > ;
    string KEY_SOUND_1 = "72a7fa0d-0e74-ca84-3894-c4eae665fac7";
    string KEY_SOUND_2 = "d302a5fa-21ae-6f55-0d1c-ec55bd58f895";
    string KEY_SOUND_3 = "7d5ef849-1f02-8399-3bb2-758833d455a1";
    string KEY_SOUND_4 = "8b76dbc1-c003-2fe7-0f2c-6c03238e0793";
    string KEY_SOUND_5 = "c9ee84ab-3ec3-ab47-9584-4bb859c2ec20";
    string KEY_SOUND_6 = "502d772c-47cc-918c-40aa-0d7df0a67e11";
    
    string KEY1;
    string KEY2;
    string KEY3;
    string KEY4;
    string KEY5;
    string KEY6;
    
    default {
        touch_end(integer total_number) {
    
    
            integer i = llGetNumberOfPrims();
    
            if (llGetLinkName(i) == KEY1)
            {
                llSay(0, "Key1");
            }                
            
        }
    }

     

  9. 5 minutes ago, Fenix Eldritch said:

    Ah ha... whoops. Yes that would be rather important, wouldn't it? My mistake. :)

    There are a number of ways to approach this. You could use a compound IF statement that check of KEY was equal to any of the desired linknumbers:

    
    if (KEY == 2 || KEY == 3 || etc...)

    Another way would be the give the piano keys the a distinct name and check if the name of the currently pressed key was equal to that. See llGetLinkName for examples.

    Thank you so much! Now its perfect!

    vector KEY_OFFSET_DN = < 0.1, 0.0, 0.0 > ;
    vector KEY_OFFSET_UP = < -0.1, 0.0, 0.0 > ;
    //string KEY_SOUND_1 = "";
    
    default {
        touch_end(integer total_number) {
            integer KEY = llDetectedLinkNumber(0);
    
            if (KEY == 23 || KEY == 22 || KEY == 21 || KEY == 20 || KEY == 19 || KEY == 18)
    
            {
                llSay(0, "Key " + (string) KEY + " pressed");
                llSetLinkPrimitiveParamsFast(KEY, [PRIM_POS_LOCAL, llList2Vector(llGetLinkPrimitiveParams(KEY, [PRIM_POS_LOCAL]), 0) + KEY_OFFSET_UP]);
                llSleep(0.1);
                llSetLinkPrimitiveParamsFast(KEY, [PRIM_POS_LOCAL, llList2Vector(llGetLinkPrimitiveParams(KEY, [PRIM_POS_LOCAL]), 0) + KEY_OFFSET_DN]);
            }
        }
    }

     

  10. vector KEY_OFFSET_UP = < 0.0, 0.0, 0.1 >;
    vector KEY_OFFSET_DN = < 0.0, 0.0, -0.1 >;
    //string KEY_SOUND_1 = "";
    
    default
    {
        touch_end(integer total_number)
        {
            integer KEY = llDetectedLinkNumber(0);
        
    llSay(0, "Key "+(string)KEY+" pressed");
    llSetLinkPrimitiveParamsFast (KEY, [PRIM_POS_LOCAL, llList2Vector(llGetLinkPrimitiveParams(KEY, [PRIM_POS_LOCAL]), 0) + KEY_OFFSET_UP]);
    llSleep(0.1);
    llSetLinkPrimitiveParamsFast (KEY, [PRIM_POS_LOCAL, llList2Vector(llGetLinkPrimitiveParams(KEY, [PRIM_POS_LOCAL]), 0) + KEY_OFFSET_DN]);
            
        }
    }
    13 minutes ago, Fenix Eldritch said:

    Firstly, you don't need to have all those IF statements. You already know what the currently touched key is, so use that KEY variable like this:

    
    llSay(0, "Key "+(string)KEY+" pressed");
    llSetLinkPrimitiveParams(KEY, [PRIM_POS_LOCAL, llList2Vector(llGetLinkPrimitiveParams(KEY, [PRIM_POS_LOCAL]), 0) + <0.0, 0.0, 1.0>]);
    llSleep(1);
    llSetLinkPrimitiveParams(KEY, [PRIM_POS_LOCAL, llList2Vector(llGetLinkPrimitiveParams(KEY, [PRIM_POS_LOCAL]), 0) + <0.0, 0.0, -1.0>]);
            

    This will make the code flexible enough to apply the position movement to whatever key was currently pressed without needing to check through every possible key.

    Secondly, you could use  llSetLinkPrimitiveParamsFast which is a variant of the function that doesn't have a built in delay on top of the explicit sleeps you have.

    Thank you so much! Just one more thing - if piano has prims which dont need to move how to make this if check?

  11. I made this experimental draft for 3 keys but it looks not very good. How to simplify it?

    default
    {
        touch_end(integer total_number)
        {
            integer KEY = llDetectedLinkNumber(0);
            if 
            (KEY == 2)
            {        
            llSay(0, "Key 1 pressed");
            llSetLinkPrimitiveParams(2, [PRIM_POS_LOCAL, llList2Vector(llGetLinkPrimitiveParams(2, [PRIM_POS_LOCAL]), 0) + <0.0, 0.0, 1.0>]);
    llSleep(1);
            llSetLinkPrimitiveParams(2, [PRIM_POS_LOCAL, llList2Vector(llGetLinkPrimitiveParams(2, [PRIM_POS_LOCAL]), 0) + <0.0, 0.0, -1.0>]);
            }
            if 
            (KEY == 3)
            {        
            llSay(0, "Key 2 pressed");
            llSetLinkPrimitiveParams(3, [PRIM_POS_LOCAL, llList2Vector(llGetLinkPrimitiveParams(3, [PRIM_POS_LOCAL]), 0) + <0.0, 0.0, 1.0>]);
    llSleep(1);
            llSetLinkPrimitiveParams(3, [PRIM_POS_LOCAL, llList2Vector(llGetLinkPrimitiveParams(3, [PRIM_POS_LOCAL]), 0) + <0.0, 0.0, -1.0>]);
            }
            if 
            (KEY == 4)
            {        
            llSay(0, "Key 3 pressed");
            llSetLinkPrimitiveParams(4, [PRIM_POS_LOCAL, llList2Vector(llGetLinkPrimitiveParams(4, [PRIM_POS_LOCAL]), 0) + <0.0, 0.0, 1.0>]);
    llSleep(1);
            llSetLinkPrimitiveParams(4, [PRIM_POS_LOCAL, llList2Vector(llGetLinkPrimitiveParams(4, [PRIM_POS_LOCAL]), 0) + <0.0, 0.0, -1.0>]); 
            }
        }
    }

     

  12. 17 minutes ago, Fenix Eldritch said:

    Better than what? What have you tried first?

    Using llSetLinkPrimitiveParamsFast with the PRIM_POS_LOCAL constant and its associated parameters and targeting the clicked prim via llDetectedLinkNumber would be the typical approach.

    Thank you! so i made my key move a bit up but how to make it move back in a second?

            llSetLinkPrimitiveParams(2, [PRIM_POS_LOCAL, llList2Vector(llGetLinkPrimitiveParams(2, [PRIM_POS_LOCAL]), 0) + <0.0, 0.0, 1.0>]);

  13. Hello! I make a small piano of 6 keys and I need to make a script so that the buttons move slightly in space when I click on them, as if someone touched them. How to do it better? It will be a linkset. Each key separate.

    I guess should start with something like:

    default
    {
        touch_end(integer total_number)
        {
            integer face = llDetectedTouchFace(0);
            if 
            (face == 1)
            {        
            llSay(0, "Key 1 pressed"); // Do something with key
            }
        }
    }

    But how to move keys? a little bit rotated and moved?

  14. 21 minutes ago, Fenix Eldritch said:

    But that's a lot of effort compared to the viewer's menu command. Is there a particular reason why you're aiming for a scripted solution?

    Hi! Indeed seems very complicated!

    my friend used this script, but complained about its inconvenience. I promised that I would try to get rid of the need to do all these operations.

  15. Hello! how to create a script that would delete all scripts from the link set and then delete itself? I found this script in wiki but it requires some additional action. is there a way to make this easier with a script?

    For convenience i post it here:

    This one is simple, and works for attachments and rezzed objects. Just drop the script in the linkset (so in the root prim). If the linkset is one single prim, there is nothing else to do. Otherwise, when the script tells you that it is ready, unrez/re-rez the object and set all scripts to running using the menu of the viewer. That's all. An hovertext shows the number of remaining prims to be cleaned up.

    integer prims;
    integer DELETE;
     
    //  remove all other scripts, then this one
    remove_scripts()
    {
        string thisScript = llGetScriptName();
     
        integer index = llGetInventoryNumber(INVENTORY_SCRIPT);
        string scriptName;
     
        //  start with last script which has the index (numberOfScripts - 1)
        do
        {
            --index;
            scriptName = llGetInventoryName(INVENTORY_SCRIPT, index);
     
            if (scriptName != thisScript)
                llRemoveInventory(scriptName);
        }
        while (index);
     
        //  at last remove this script
        llRemoveInventory(thisScript);
    }
     
    default
    {
        state_entry()
        {
            //  set an ident number code
            DELETE = (integer) ("0x" + (string) llGetOwner() );
            integer link = llGetLinkNumber();
     
            //  the root prim has link number 0 for single prim objects and 1 for linksets
            if (link < 2)
            {
                prims = llGetObjectPrimCount(llGetKey() );        // Get number of prims excluding seated avatars
     
                //  if single prim, else linkset
                if (prims == 1)
                {
                    llSay(0, "Done removing scripts.");
                    remove_scripts();
                }
                else
                {
                    integer n = prims;
                    while(n > 1)
                    {
                        llGiveInventory(llGetLinkKey(n), llGetScriptName());
                        --n;
                    }
                    llSay(0, "Please take this object back to your inventory and "
                        + "rez it again. Then edit the object (ctrl+3), go to the menu at the "
                        + "top of your viewer and select BUILD > SCRIPTS > SET SCRIPTS TO RUNNING.");
                }
            }
            else//  not the root prim
            {
                llMessageLinked(LINK_ROOT, DELETE, "", NULL_KEY);
                remove_scripts();
            }
        }
     
        link_message(integer sender_num, integer num, string str, key id)
        {
            //  if the received linkmessage contains the ident number code previously stored...
            if (num == DELETE)
            {
                --prims;
                if (prims == 1)
                {
                    llSay(0, "Done removing scripts.");
                    remove_scripts();
                }
            }
        }
    }

    No need for chat and other messages, just deletion...

  16. 27 minutes ago, Rolig Loon said:

    Drat.  Of course Fenix isright.  This is why we have to remember to include the exculpatory warning in this forum every once in a while:

    "Warning: Scripts posted here have usually not been tested in world.  There is no guarantee that they are bug free, ."

    All of which is no excuse, but is an explanation.  Yes, just make a global key variable  (key kAv) and then assign it in the touch_start event:

    kAv = llDetectedKey(0);

    Then refer to that in the run_time_permissions event.

     

    35 minutes ago, Fenix Eldritch said:

    llDetectedKey (and related functions) only work within a small subset of events - as per the wiki page specifications:

    So trying to use it in the run_time_permissions event won't work. If you want to reference the user's key that you detected in the touch_start event, you must store it in a global variable.

    Guys you are awesome! Thank you again! another version works

    list MENU_MAIN = ["STOP", "Dance1", "Dance2", "Dance3"]; 
    string sound = "a78fd32e-0179-437b-9a39-6b24916aa433";
    integer menu_handler;
    integer menu_channel;
    key kAv;
    KillAnims()
    
    {
    
        llStopAnimation("Dance1");
        llStopObjectAnimation("Dance1");
    
        llStopAnimation("Dance2");
        llStopObjectAnimation("Dance2");
    
        llStopAnimation("Dance3");
        llStopObjectAnimation("Dance3");
    
    }
    
    menu(key user, string title, list buttons)
    {
        llListenRemove(menu_handler); 
        menu_channel = (integer)(llFrand(99999.0) * -1);
        menu_handler = llListen(menu_channel, "", "", "");
        llDialog(user, title, buttons, menu_channel);
        llSetTimerEvent(30.0); 
    }
    
    default
    {
        state_entry()
        {
               
        }
    
        run_time_permissions(integer perm)
        {
            if (perm & PERMISSION_TRIGGER_ANIMATION)
            {
    
            menu(kAv, "\nText for Menu.", MENU_MAIN);
        
            }
        }
    
        changed(integer change)
    
        {
            if (change & CHANGED_OWNER)
            {
                llResetScript();
            }
        }
    
        touch_start(integer total_number)
        {
            
            if (llDetectedKey(0) == llGetOwnerKey(llGetKey()))
            {
            llRequestPermissions(llDetectedKey(0), PERMISSION_TRIGGER_ANIMATION);
            kAv = llDetectedKey(0);
            }
    
        }
        
      
        
    
        listen(integer channel, string name, key id, string message)
        {
    
            llListenRemove(menu_handler);
    
            llSetTimerEvent(0.0);
    
            KillAnims();
    
            integer idx = llListFindList(["Dance1", "Dance2", "Dance3"], [message]);
    
            if (~idx)
    
            {
    
                llStartAnimation(message);
                llStartObjectAnimation(message);
    
            }
    
        }
    
        timer() 
        {
            llListenRemove(menu_handler); 
            llSetTimerEvent(0); 
        }
    }

     

    • Like 1
  17. About Rolig Loon's version i still would like to understand - why i cant get menu to appear?

    list MENU_MAIN = ["STOP", "Dance1", "Dance2", "Dance3"]; //up to 12 in list
    string sound = "a78fd32e-0179-437b-9a39-6b24916aa433";
    integer menu_handler;
    integer menu_channel;
    
    KillAnims()
    
    {
    
        llStopAnimation("Dance1");
        llStopObjectAnimation("Dance1");
    
        llStopAnimation("Dance2");
        llStopObjectAnimation("Dance2");
    
        llStopAnimation("Dance3");
        llStopObjectAnimation("Dance3");
    
    }
    
    menu(key user, string title, list buttons)
    {
        llListenRemove(menu_handler); 
        menu_channel = (integer)(llFrand(99999.0) * -1);
        menu_handler = llListen(menu_channel, "", "", "");
        llDialog(user, title, buttons, menu_channel);
        llSetTimerEvent(30.0); 
    }
    
    default
    {
        state_entry()
        {
            
        }
    
        run_time_permissions(integer perm)
        {
            if (perm & PERMISSION_TRIGGER_ANIMATION)
            {
            menu(llDetectedKey(0), "\nText for Menu.", MENU_MAIN);
            }
        }
    
        changed(integer change)
    
        {
            if (change & CHANGED_OWNER)
            {
                llResetScript();
            }
        }
    
        touch_start(integer total_number)
        {
            
            if (llDetectedKey(0) == llGetOwnerKey(llGetKey()))
            {
            llRequestPermissions(llDetectedKey(0), PERMISSION_TRIGGER_ANIMATION);
            }
    
        }
    
        listen(integer channel, string name, key id, string message)
        {
    
            llListenRemove(menu_handler);
    
            llSetTimerEvent(0.0);
    
            KillAnims();
    
            integer idx = llListFindList(["Dance1", "Dance2", "Dance3"], [message]);
    
            if (~idx)
    
            {
    
                llStartAnimation(message);
                llStartObjectAnimation(message);
    
            }
    
        }
    
        timer() 
        {
            llListenRemove(menu_handler); 
            llSetTimerEvent(0); 
        }
    }

     

  18. Thank you all very much! Now absolutely no errors!

    list MENU_MAIN = ["STOP", "Dance1", "Dance2", "Dance3"];
    string sound = "a78fd32e-0179-437b-9a39-6b24916aa433";
    integer menu_handler;
    integer menu_channel;
    string lastDance = "";
    string nextDance = "";
    menu(key user, string title, list buttons)
    {
        llListenRemove(menu_handler);
        menu_channel = (integer)(llFrand(99999.0) * -1);
        menu_handler = llListen(menu_channel, "", "", "");
        llDialog(user, title, buttons, menu_channel);
        llSetTimerEvent(30.0);
    }
    
    default
    {
        state_entry()
        {
            llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
        }
    
        run_time_permissions(integer perm)
        {
            if (perm & PERMISSION_TRIGGER_ANIMATION)
            {
                if (lastDance != "")
                {
                    llStopAnimation(lastDance);
                    llStartAnimation(nextDance);
                    lastDance = nextDance;
                }
            }
    
        }
    
        touch_start(integer total_number)
        {
            menu(llDetectedKey(0), "\nText for Menu.", MENU_MAIN);
        }
    
        listen(integer channel, string name, key id, string message)
        {
            if (channel == menu_channel)
            {
                llListenRemove(menu_handler);
                llSetTimerEvent(0);
                if (message == "Dance1")
                {
                    nextDance = message;
                    llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
                    llStartAnimation("Dance1");
                    llStartObjectAnimation("Dance1");
                    llStopAnimation("Dance2");
                    llStopObjectAnimation("Dance2");
                    llStopAnimation("Dance3");
                    llStopObjectAnimation("Dance3");
                }
                else if (message == "Dance2")
                {
                    nextDance = message;
                    llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
                    llStopAnimation("Dance1");
                    llStopObjectAnimation("Dance1");
                    llStopAnimation("Dance3");
                    llStopObjectAnimation("Dance3");
                    llStartAnimation("Dance2");
                    llStartObjectAnimation("Dance2");
                }
                else if (message == "Dance3")
                {
                    nextDance = message;
                    llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
                    llStopAnimation("Dance2");
                    llStopObjectAnimation("Dance2");
                    llStopAnimation("Dance1");
                    llStopObjectAnimation("Dance1");
                    llStartAnimation("Dance3");
                    llStartObjectAnimation("Dance3");
                }
    
                else if (message == "STOP")
                {
                    llStopAnimation("Dance1");
                    llStopObjectAnimation("Dance1");
                    llStopAnimation("Dance2");
                    llStopObjectAnimation("Dance2");
                    llStopAnimation("Dance3");
                    llStopObjectAnimation("Dance3");
                }
            }
        }
    
        timer()
        {
            llListenRemove(menu_handler);
            llSetTimerEvent(0);
        }
    }
    
        

     

  19. 12 hours ago, Profaitchikenz Haiku said:

    What is the error exactly? The script doesn't have any syntax errors so it must be something like the specified animation not found?

    Hi! First error was  "Script trying to trigger animations but PERMISSION_TRIGGER_ANIMATION permission not set"

    I thank you very much and i tried what you advised and it almost works - now i have two errors:

    [02:57] Could not find animation '' - when i wear it (or reset script)
    [02:57] Could not find animation 'STOP' - when i hit stop. Please help to finish it.

     

    EDIT: ok i fixed animation 'STOP' error but one remains - if i reset script - [03:27] Could not find animation '' why it happens?

    list MENU_MAIN = ["STOP", "Dance1", "Dance2", "Dance3"];
    string sound = "a78fd32e-0179-437b-9a39-6b24916aa433";
    integer menu_handler;
    integer menu_channel;
    string lastDance = "";
    string nextDance = "";
    menu(key user, string title, list buttons)
    {
        llListenRemove(menu_handler);
        menu_channel = (integer)(llFrand(99999.0) * -1);
        menu_handler = llListen(menu_channel, "", "", "");
        llDialog(user, title, buttons, menu_channel);
        llSetTimerEvent(30.0);
    }
    
    default
    {
        state_entry()
        {
            llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
        }
    
        run_time_permissions(integer perm)
        {
            if (perm & PERMISSION_TRIGGER_ANIMATION)
            {
                if (lastDance != "") llStopAnimation(lastDance);
                llStartAnimation(nextDance);
                lastDance = nextDance;
            }
    
        }
    
        changed(integer change)
    
        {
            if (change & CHANGED_OWNER)
            {
                llResetScript();
            }
        }
    
        touch_start(integer total_number)
        {
            menu(llDetectedKey(0), "\nText for Menu.", MENU_MAIN);
        }
    
        listen(integer channel, string name, key id, string message)
        {
            if (channel == menu_channel)
            {
                llListenRemove(menu_handler);
                llSetTimerEvent(0);
                if (message == "Dance1")
                {
                    nextDance = message;
                    llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
                    llStartAnimation("Dance1");
                    llStartObjectAnimation("Dance1");
                    llStopAnimation("Dance2");
                    llStopObjectAnimation("Dance2");
                    llStopAnimation("Dance3");
                    llStopObjectAnimation("Dance3");
                }
                else if (message == "Dance2")
                {
                    nextDance = message;
                    llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
                    llStopAnimation("Dance1");
                    llStopObjectAnimation("Dance1");
                    llStopAnimation("Dance3");
                    llStopObjectAnimation("Dance3");
                    llStartAnimation("Dance2");
                    llStartObjectAnimation("Dance2");
                }
                else if (message == "Dance3")
                {
                    nextDance = message;
                    llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
                    llStopAnimation("Dance2");
                    llStopObjectAnimation("Dance2");
                    llStopAnimation("Dance1");
                    llStopObjectAnimation("Dance1");
                    llStartAnimation("Dance3");
                    llStartObjectAnimation("Dance3");
                }
    
                else if (message == "STOP")
                {
                    llStopAnimation("Dance1");
                    llStopObjectAnimation("Dance1");
                    llStopAnimation("Dance2");
                    llStopObjectAnimation("Dance2");
                    llStopAnimation("Dance3");
                    llStopObjectAnimation("Dance3");
                }
            }
        }
    
        timer()
        {
            llListenRemove(menu_handler);
            llSetTimerEvent(0);
        }
    }

     

  20. 11 hours ago, Rolig Loon said:

    You didn't say what the error is, but you don't really have to put anything in that run_time_permissions event except maybe a line of chat to reassure you that you actually gave the script permission.  

    Hi! Thank you very much!

    First error was  "Script trying to trigger animations but PERMISSION_TRIGGER_ANIMATION permission not set"

    I did everything like you wrote but now i cant get rid of error "Function call mismatches"...

    And it refuses to give a menu maybe cause i moved it to run_time_permissions.

    what am i doing wrong? everything else is just perfect!

    list MENU_MAIN = ["STOP", "Dance1", "Dance2", "Dance3"]; //up to 12 in list
    string sound = "a78fd32e-0179-437b-9a39-6b24916aa433";
    integer menu_handler;
    integer menu_channel;
    
    KillAnims()
    
    {
    
        llStopAnimation("Dance1");
        llStopObjectAnimation("Dance1");
    
        llStopAnimation("Dance2");
        llStopObjectAnimation("Dance2");
    
        llStopAnimation("Dance3");
        llStopObjectAnimation("Dance3");
    
    }
    
    menu(key user, string title, list buttons)
    {
        llListenRemove(menu_handler); 
        menu_channel = (integer)(llFrand(99999.0) * -1);
        menu_handler = llListen(menu_channel, "", "", "");
        llDialog(user, title, buttons, menu_channel);
        llSetTimerEvent(30.0); 
    }
    
    default
    {
        state_entry()
        {
    
        }
    
        run_time_permissions(integer perm)
        {
            if (perm & PERMISSION_TRIGGER_ANIMATION)
            {
                menu(llDetectedKey(0), "\nText for Menu.", MENU_MAIN);
            }
        }
    
        changed(integer change)
    
        {
            if (change & CHANGED_OWNER)
            {
                llResetScript();
            }
        }
    
        touch_start(integer total_number)
        {
            
            if (llDetectedKey(0) == llGetOwnerKey()) // <- error here  "llGetOwnerKey(error here)"
            {
                llRequestPermissions(llDetectedKey(0), PERMISSION_TRIGGER_ANIMATION);
            }
    
        }
    
        listen(integer channel, string name, key id, string message)
        {
    
            llListenRemove(menu_handler);
    
            llSetTimerEvent(0.0);
    
            KillAnims();
    
            integer idx = llListFindList(["Dance1", "Dance2", "Dance3"], [message]);
    
            if (~idx)
    
            {
    
                llStartAnimation(message);
                llStartObjectAnimation(message);
    
            }
    
        }
    
        timer() 
        {
            llListenRemove(menu_handler); 
            llSetTimerEvent(0); 
        }
    }

     

  21. Hello! I am trying to script animesh dancing character, which will also animate avatar so they dance together. Everything is fine, when one dance used, but now i need to add a menu for multiple dances and i have an error, i know its something about

        run_time_permissions(integer perm)
        {
            if (perm & PERMISSION_TRIGGER_ANIMATION)
            {
                // what to do here
            }
        }

    and it must be the list, i am afraid. cause i am not good in lists.

    list MENU_MAIN = ["STOP", "Dance1", "Dance2", "Dance3"];
    string sound = "a78fd32e-0179-437b-9a39-6b24916aa433";
    integer menu_handler;
    integer menu_channel;
    menu(key user, string title, list buttons)
    {
        llListenRemove(menu_handler);
        menu_channel = (integer)(llFrand(99999.0) * -1);
        menu_handler = llListen(menu_channel, "", "", "");
        llDialog(user, title, buttons, menu_channel);
        llSetTimerEvent(30.0);
    }
    
    default
    {
        state_entry()
        {
            llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
        }
    
        run_time_permissions(integer perm)
        {
            if (perm & PERMISSION_TRIGGER_ANIMATION)
            {
                // what to do here
            }
        }
    
        changed(integer change)
    
        {
            if (change & CHANGED_OWNER)
            {
                llResetScript();
            }
        }
    
        touch_start(integer total_number)
        {
            menu(llDetectedKey(0), "\nText for Menu.", MENU_MAIN);
        }
    
        listen(integer channel, string name, key id, string message)
        {
            if (channel == menu_channel)
            {
                llListenRemove(menu_handler);
                llSetTimerEvent(0);
                if (message == "Dance1")
                {
                    llStopAnimation("Dance2");
                    llStopObjectAnimation("Dance2");
                    llStopAnimation("Dance3");
                    llStopObjectAnimation("Dance3");
                    llStartAnimation("Dance1");
                    llStartObjectAnimation("Dance1");
                }
                else if (message == "Dance2")
                {
                    llStopAnimation("Dance1");
                    llStopObjectAnimation("Dance1");
                    llStopAnimation("Dance3");
                    llStopObjectAnimation("Dance3");
                    llStartAnimation("Dance2");
                    llStartObjectAnimation("Dance2");
                }
                else if (message == "Dance3")
                {
                    llStopAnimation("Dance2");
                    llStopObjectAnimation("Dance2");
                    llStopAnimation("Dance1");
                    llStopObjectAnimation("Dance1");
                    llStartAnimation("Dance3");
                    llStartObjectAnimation("Dance3");
                }
    
                else if (message == "STOP")
                {
                    llStopAnimation("Dance1");
                    llStopObjectAnimation("Dance1");
                    llStopAnimation("Dance2");
                    llStopObjectAnimation("Dance2");
                    llStopAnimation("Dance3");
                    llStopObjectAnimation("Dance3");
                }
            }
        }
    
        timer()
        {
            llListenRemove(menu_handler);
            llSetTimerEvent(0);
        }
    }

     

  22. On 10/18/2019 at 6:33 AM, KT Kingsley said:

    You can change the direction of the animation using the texture rotation setting, either in the build floater manually, or by script.

    Yes, i can, but when i drop this script in it changes back to default, no matter manually or by piece of code.

    I mean, now it goes from left to right, and if i rotate the texture to 90 ° it will simply go from top to bottom etc. Animation follows the texture....

×
×
  • Create New...