Jump to content

Leo1452

Resident
  • Posts

    17
  • Joined

  • Last visited

Posts posted by Leo1452

  1. On 9/25/2021 at 4:39 AM, Mollymews said:

    replicating the issue

    two scripts

    link two prims

    put both script(1) and script(2) in the same prim. Sit two avatars in different viewers on the same computer

    both scripts will accept control inputs from either viewer with the focus

    stick script(1) and script(2) into different prims

    script(1) will only accept control inputs from viewer(1). Script(2) will only accept control inputs from viewer(2)

    /

    / script 1
    
    default
    {
        state_entry()
        {
            llLinkSitTarget(1,<0.0,0.0,0.5>,ZERO_ROTATION);
            llLinkSitTarget(2, <0.0,0.0,0.5>,ZERO_ROTATION);
        }
    
        changed(integer change)
        {
            if(change & CHANGED_LINK)
            {
                key agent = llAvatarOnLinkSitTarget(1);
                if (agent)
                {
                    llRequestPermissions(agent, PERMISSION_TAKE_CONTROLS);
                }
                else
                {
                    llReleaseControls();   
                }
            }
        }
        
        run_time_permissions(integer perms)
        {
            if (perms & PERMISSION_TAKE_CONTROLS)
            {
                llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_LEFT | CONTROL_RIGHT | CONTROL_UP | CONTROL_DOWN, TRUE, FALSE);    
            }  
        }
        
        control(key id, integer level, integer edge)
        {
            llWhisper(0, llDumpList2String(["script 1", id, level, edge], " "));     
        }
    }
    // script 2
    default
    {
        changed(integer change)
        {
            if(change & CHANGED_LINK)
            {
                key agent = llAvatarOnLinkSitTarget(2);
                if (agent)
                {
                    llRequestPermissions(agent, PERMISSION_TAKE_CONTROLS);
                }
                else
                {
                    llReleaseControls();   
                }
            }
        }
        
        run_time_permissions(integer perms)
        {
            if (perms & PERMISSION_TAKE_CONTROLS)
            {
                llTakeControls(CONTROL_LEFT | CONTROL_RIGHT | CONTROL_ML_LBUTTON, TRUE, FALSE);    
            }  
        }
        
        control(key id, integer level, integer edge)
        {
            llWhisper(0, llDumpList2String(["script 2", id, level, edge], " "));      
        }
    }

    ps add

    is a interesting effect this - both scripts in the root prim

    as could control two avatars (the driver and the gunner) from the same RL keyboard.  Using the "C" and "E" keys as control keys to distinguish between the two. Example:

    driver: level = W,A,S,D.  E + W,A,S,D. (8 controls)

    gunner: level = C + W,A,S,D. LMB. (5 controls)

     

    So I got around to trying the scripts in separate prims, they still interfere with each other. Do you have any other suggestions?

  2. 38 minutes ago, Mollymews said:

     

    without seeing your script then am not sure what the issue might be

    a way to help see what might be happening is to check the value of key id in the control event parameters against the id of the agent for which the script has permission

    control (key id, integer level, integer edge)
    {
       if (id != llGetPermissionsKey())
       {
           llOwnerSay("control id is not the same as script permissions id")
       }
    }

     

    Both scripts are in the same prim.

    The driver script has these pieces to handle control:

    llRequestPermissions(llAvatarOnLinkSitTarget(1), PERMISSION_TAKE_CONTROLS);
    
    run_time_permissions(integer k)
        {
            if(k & PERMISSION_TAKE_CONTROLS)
            {
                llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_LEFT | CONTROL_UP | CONTROL_DOWN, TRUE, FALSE);
            }
        }
    
    control(key n, integer l, integer e)
        {
            if(llAvatarOnLinkSitTarget(1) != NULL_KEY && n == llGetPermissionsKey())
    		{
    		}
    	}

    The turret script has these pieces:

    llRequestPermissions(llAvatarOnLinkSitTarget(2), PERMISSION_TAKE_CONTROLS);
    
    run_time_permissions(integer k)
        {
            if(k & PERMISSION_TAKE_CONTROLS)
            {
                llTakeControls(CONTROL_LEFT | CONTROL_RIGHT | CONTROL_ML_LBUTTON, TRUE, FALSE);
            }
        }
    
    control(key n, integer l, integer e)
        {
            if(llAvatarOnLinkSitTarget(2) != NULL_KEY && n == llGetPermissionsKey())
    		{
    		}
    	}

    When I add your code to test it, "control id is not the same as script permissions id" never happens. I sat two avatars from different viewers, but no matter which avatar I control from, it registers as the driver sending controls.

  3. I want to make a tank that seats two avatars. llAvatarOnLinkSitTarget(1) will drive the tank while llAvatarOnLinkSitTarget(2) will control the turret. I have separate scripts handle the driving and turret. The driving script only calls llRequestPermissions() on the driver avatar while the turret script only calls llRequestPermissions() on the turret avatar. I also add if-statements above all controls to make sure the key of the avatar's control is coming from the appropriate avatar. I'm clearly still missing something because both scripts still respond to the controls of both avatars. Can someone help me?

     Both scripts are in the same prim.

    The driver script has these pieces to handle control:

    llRequestPermissions(llAvatarOnLinkSitTarget(1), PERMISSION_TAKE_CONTROLS);
    
    run_time_permissions(integer k)
        {
            if(k & PERMISSION_TAKE_CONTROLS)
            {
                llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_LEFT | CONTROL_UP | CONTROL_DOWN, TRUE, FALSE);
            }
        }
    
    control(key n, integer l, integer e)
        {
            if(llAvatarOnLinkSitTarget(1) != NULL_KEY && n == llGetPermissionsKey())
    		{
    		}
    	}

    The turret script has these pieces:

    llRequestPermissions(llAvatarOnLinkSitTarget(2), PERMISSION_TAKE_CONTROLS);
    
    run_time_permissions(integer k)
        {
            if(k & PERMISSION_TAKE_CONTROLS)
            {
                llTakeControls(CONTROL_LEFT | CONTROL_RIGHT | CONTROL_ML_LBUTTON, TRUE, FALSE);
            }
        }
    
    control(key n, integer l, integer e)
        {
            if(llAvatarOnLinkSitTarget(2) != NULL_KEY && n == llGetPermissionsKey())
    		{
    		}
    	}
  4. On 5/26/2021 at 11:38 AM, Quistess Alpha said:
    llSetRot(llEuler2Rot(<0,PI_BY_TWO,0>)*rot);

    to combine rotations on different axes you need to multiply them together (the order is important as well). (PI_BY_TWO is 90 degrees in radians)

    Thank you very much. I have a follow-up question for anyone who can help. I have a non-physical object rotated forward 90 degrees using this line of code. I want to restrict its rotation so that it can only rotate on the z axis. I would code something to nullify the x and y axis rotations so that it's always upright no matter how someone tries to edit the rotation. However, with the object rotated 90 degrees forward, the -x axis replaces the z axis as the new "upright." How do I do this given that the three axes are no longer independent?

  5. timer()
        {
            list details = llGetObjectDetails(id, [OBJECT_POS, OBJECT_ROT]);
            rotation rot = llList2Rot(details, 1) ;
            llSetPos(llList2Vector(details, 0) + <0.0, -0.5, 0.75>*rot); //The follower floats -0.5 on the y-axis and 0.75 on the z axis from the target
            llSetRot(<rot.x, PI, rot.z, 1>);
        }

    This timer is for a follow that follows the object with the UUID of "id." The follower is only to rotate on the z-axis to face the same direction as the target. I want to rotate the object 90-degrees along the y-axis so that its top faces forward instead. However, when I try to set the rotation to <0, 90, 0>, it seems to turn all over the place. I know that there's a mathematical reason why, but I have no idea how to fix this.

  6. I'm making a sort of laser beam game where people ride cars that shoot blasts. The cars don't move with physics. The blasts should pass through through everything except the cars that are part of the game. Is there a way to make a bullet that only collides with objects of a certain name? If not, is there a way to make a phantom bullet that notices when it's passed through objects of a certain name so that it can perform some sort of reaction?

  7. I'd have a listener on channel 0. For every message in nearby chat, it would check if that string contains a substring from a list in my script and perform some action if it finds one. To see if a message contains the word "happy," I'd use llSubStringIndex(llToLower(message), "happy") but how about a whole list of words I'm looking for?

  8. 14 minutes ago, DoteDote Edison said:

    Interesting question because if the script is attached to you and if it can only hear chat within 20m, and if you set it to ignore anything within 20m, then everything it hears will fall into the 20m range and thus be ignored.

    Nevertheless, to get the distance of the avatar speaking, use "list details = llGetObjectDetails(id, [OBJECT_POS])" to get their position.  "id" is the key of the avatar returned by the listen() event.  That function will return a single-item list, so convert to vector using "vector pos = llList2Vector(details, 0)".  Then, do "float distance =  llVecDist(llGetPos(), pos)"  with llGetPos() as your position.  "If (distance >  20.0) llOwnerSay()".

    Hi. Sorry, I shouldn't have said the object is attached to me. Let's say that the object is on the ground. How can it know the distance between me and the person/object that just spoke?

  9. This is a script that will repeat anything that it hears in nearby chat within 20m to the owner. This script will be in an object within range of a few people. If I'm already in range of the person who sent the chat, it will repeat it to me twice, which is unfavourable. How do I detect if the person who sent the chat in nearby is already within 20 metres of the owner (me)? If I could add an if statement around the llOwnerSay() that only repeats a message when I'm out of the 20 m range of the avatar or object that sent it, that'd be great.

    integer nearby;
     
    default
    {
        state_entry()
        {
            nearby = llListen(0, "", "", "");
        }
     
        listen(integer channel, string name, key id, string message)
        {
            llOwnerSay(message);
        }
    }

     

  10. Here's an example of an avatar bumper sound script. Is there a way for it to only detect horizontal collisions such that if you tp on someone's head, it doesn't play. This is for people with tp sounds because one sound will interrupt the other.

    float volume = 1.0; //Volume 0.0 - 1.0;
    default
    {
        collision_start(integer num)
        {
            if(llDetectedType(0) & AGENT)
            {
                llStartAnimation("lulz");
                llPlaySound(llGetInventoryName(INVENTORY_SOUND,llFloor(llFrand(llGetInventoryNumber(INVENTORY_SOUND)))),1.0);
                llSetTimerEvent(1.0);
            }
        }
        timer()
        {
            llStopAnimation("lulz");
        }
        attach(key uid)
        {
            if(llGetAttached())
                llRequestPermissions(llGetOwner(),PERMISSION_TRIGGER_ANIMATION);
        }
    }

     

  11. // Play a sound whenever the owner is walking
    integer   gWasWalking;             // TRUE when wearer is already walking
    string    gSound = "Sleepwalk";    // name of soundfile in inventory
    default
    {
        state_entry()
        {
            // Start a timer to continuously check if the owner is walking
            llSetTimerEvent(0.25);
        }
        timer()
        {
            integer NowWalking = llGetAgentInfo(llGetOwner()) & AGENT_WALKING;
            if  (NowWalking != gWasWalking)        // walking has stopped or started
            {
                llStopSound();
                if (NowWalking)
                    llLoopSound(gSound, 1.0);
            }
            gWasWalking = NowWalking;
        }
    }

     

  12. Below is a basic walker script that's been shared around. Whenever I teleport to a person or location, it starts playing. I want make sure that it can't play until (let's say) 5 seconds after every teleport. It's because I already have a teleport sound player, so I don't want them both playing at the same time. I've tried adding llSleep(), but that just causes it to play 5 seconds later, even though I'm not even walking by then. I just want it to act as if I didn't walk at all no matter what my avatar does during the 5 seconds after every teleport.

    string Snd = "Sleepwalk";
    integer For = AGENT_WALKING;
    default
    {
        state_entry()
        {
            llPreloadSound(Snd);
            state entry;
        }
    }
    state entry
    {
        state_entry()
        {
            llStopSound();
            @D;
            if (llGetAgentInfo(llGetOwner()) & For)
            {
                llSleep(2.0);
                state walking;
            }
            jump D;
        }
    }
    state walking
    {
        state_entry()
        {
            llLoopSound(Snd,.0);
            float alpha = 0.0;
            @DD;
            llAdjustSoundVolume(alpha);
            alpha +=.1;
            if(alpha >= 1.0){jump D;}
            jump DD;
            @D;
            if (!(llGetAgentInfo(llGetOwner()) & For))
            {
                float alpha = 1.0;
                @DXD;
                llAdjustSoundVolume(alpha);
                alpha -=.1;
                if(alpha < 0.0){jump DX;}
                jump DXD;
                @DX;
                state entry;
            }
            jump D;
        }
    }

     

  13. I find that the walker scripts people are sharing around are too sensitive. You TP on someone's head and it starts playing, which isn't great for me because it already has a TP sound. I've tried adding llSleep() but that just causes the sound to come in late. I wanna prevent the following basic walker from playing unless I walk for 5 seconds.

    string Snd = "Sleepwalk";
    integer For = AGENT_WALKING;
    default
    {
        state_entry()
        {
            llPreloadSound(Snd);
            state entry;
        }
    }
    state entry
    {
        state_entry()
        {
            llStopSound();
            @D;
            if (llGetAgentInfo(llGetOwner()) & For)
            {
                llSleep(2.0);
                state walking;
            }
            jump D;
        }
    }
    state walking
    {
        state_entry()
        {
            llLoopSound(Snd,.0);
            float alpha = 0.0;
            @DD;
            llAdjustSoundVolume(alpha);
            alpha +=.1;
            if(alpha >= 1.0){jump D;}
            jump DD;
            @D;
            if (!(llGetAgentInfo(llGetOwner()) & For))
            {
                float alpha = 1.0;
                @DXD;
                llAdjustSoundVolume(alpha);
                alpha -=.1;
                if(alpha < 0.0){jump DX;}
                jump DXD;
                @DX;
                state entry;
            }
            jump D;
        }
    }

     

×
×
  • Create New...