Jump to content

Help with glasses script.


glawrence Congrejo
 Share

You are about to reply to a thread that has been inactive for 3109 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hi there,
How are your guys? As you can see, I'm a complete newbie in this forum but I hope you help me out.

I'm trying to make simple script to move a Glasses To Head and To Face.

I have two problems:
- I need to make the script work in a random Chanel or Owner only. (What's more effective/safe);
- I Have the coordinates of my avatars targets( above the noise and above the head[preventing hair]). The glasses keeps turning without the correct position.

Please try to explain to me what you doing, I realy want to learn.

Thanks

There is the code:

 

list buttons = ["Reset", "To Face", "To Head"];
string dialogInfo = "\nPlease make a choice.";
 
key ToucherID;
integer dialogChannel;
integer listenHandle;
 
default
{
    state_entry()
    {
        dialogChannel = -1 - (integer)("0x" + llGetSubString( (string)llGetKey(), -7, -1) );
    }
 
    touch_start(integer num_detected)
    {
        ToucherID = llDetectedKey(0);
        llListenRemove(listenHandle);
        listenHandle = llListen(dialogChannel, "", ToucherID, "");
        llDialog(ToucherID, dialogInfo, buttons, dialogChannel);
        llSetTimerEvent(10.0); // To prevent
    }
 
    listen(integer channel, string name, key id, string message)
    {
        if (message == "Reset")
        {
            llDialog(ToucherID, dialogInfo, buttons, dialogChannel);
          llSetPrimitiveParams([PRIM_POSITION, <-0.02654, 0.00000, 0.01689>, PRIM_ROTATION, <0.00000, 90.00000, 0.00000,1.0>]); 
// Primitive head position
            return;
            llResetScript();
        }
 
        llListenRemove(listenHandle);
        //  stop timer since the menu was clicked
        llSetTimerEvent(0);
 
        if (message == "To Head")
        {
        llSetPrimitiveParams([PRIM_POSITION, <-0.02654,-0.00001, 0.08305>, PRIM_ROTATION, <357.00000, 72.00000, 0.00000,1.0>]);
        }
        else if (message == "To Face")
        {
        llSetPrimitiveParams([PRIM_POSITION, <-0.02654, 0.00000, 0.01689>, PRIM_ROTATION, <0.00000, 90.00000, 0.00000,1.0>]);         
        } 
    }
 
    timer()
    {
    //  stop timer
        llSetTimerEvent(0);
 
        llListenRemove(listenHandle);
        llWhisper(0, "Sorry. You snooze; you lose.");
    }
}

 

Link to comment
Share on other sites

The first of your problems isn't so much a problem as a matter of choice.  There's no particular need for a random channel other than the one you are already generating from the object's UUID.  A random one won;t be any more unique than that.  The only minor improvement I'd suggest is using

dialogChannel = (integer)("0xF" + llGetSubString(llGetKey(),-7, -1);

instead of what you have now. It will be negative automatically.

It would be smart to make it triggerable by the owner only, though.  Just  make your touch_start event look like

touch_start(integer num_detected)    {        if (llGetOwner() == llDetectedKey(0))        {            llListenRemove(listenHandle);            listenHandle = llListen(dialogChannel, "", llGetOwner(), "");            llDialog(llGetOwner(), dialogInfo, buttons, dialogChannel);            llSetTimerEvent(10.0); // To prevent        }    }

I'm not sure what to say about your second problem, because I'm not exactly sure what you mean by "The glasses keeps turning without the correct position."  It looks like you are using the global position of the glasses rather than their local position, though, so I suspect that's the root of your problem.  You try to set their position to a spot that's halfway across the region (or at least more than 10m away), so nothing happens.  Instead, use llGetLinkPrimitiveParams [PRIM_POS_LOCAL] to get the "Reset" position of the glasses and then apply a local offset relative to that when you want to move them.

 

  • Like 1
Link to comment
Share on other sites

First of all you should fix your rotations. If you want to apply degrees, you will have to convert them to radians like this:

change <0.00000, 90.00000, 0.00000,1.0>tollEuler2Rot(<0.00000, 90.00000, 0.00000> * DEG_TO_RAD)

and

<357.00000, 72.00000, 0.00000,1.0>tollEuler2Rot(<357.00000, 72.00000, 0.00000> * DEG_TO_RAD)

http://wiki.secondlife.com/wiki/Rotation

 

  • Like 1
Link to comment
Share on other sites

Thanks all for your help, you're awesome.

I followed your tips,  removed the "Reset" button because it was only to prevent a "space invader glasses", if I eject the glasses away.

Allok, but I receive themsg

llSetPrimitiveParams error running rule #2: non-integer rule.


I know there is missing a "integer MISSING RULE" in the beginning of the script but don't know how to insert it.

Link to comment
Share on other sites

Since I can't see what your script looks like now, I can only guess, but I'm going to guess that you used llGetLinkPrimitiveParams to get the local position but forgot to tell it which link (an integer) to look at.  If your glasses are a single prim, though, you could have retrieved the local position with llGetLocalPos instead. 

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3109 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...