Change font size
It is currently Fri Jan 18, 2019 6:16 am

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 1   [ 4 posts ]
Author Message
 Post subject: REFERENCE: change event values / constants
PostPosted: Sun Oct 24, 2010 9:14 am 
OSG Elite
User avatar

Joined: Wed Mar 11, 2009 3:57 pm
Posts: 444
I'm posting this here as a reference for people using OpenSim. Many of us use the change event in our scripts, notably CHANGED_OWNER etc. Well the bit value's have changed a little to match with SL's changes so I'm posting the values here.

I strongly Recommend the checking of CHANGED_REGION_RESTART / CHANGED_REGION_START and reset the scripts etc, particularly handy for Sit Scripts etc.

These Values are Extracted from OpenSim Source Code: @ \OpenSim\Region\ScriptEngine\Shared\Api\Runtime\LSL_Constants.cs

CODE SNIPPET for change event:
{L_CODE}:
    changed(integer change)
    {
        // The 1024 Bit needs to be checked so the listen_handle is refreshed on region restart
        // same bitmask for CHANGED_REGION_RESTART = 1024; CHANGED_REGION_START = 1024; //LL Changed the constant from CHANGED_REGION_RESTART
        if(change & 1024)
        {
            llResetScript();
        }
        if (change & CHANGED_OWNER)
        {
            llOwnerSay("The owner of the object has changed.");
        }
    }


The Values for the CONSTANTS
{L_CODE}:
CHANGED_INVENTORY = 1;
CHANGED_COLOR = 2;
CHANGED_SHAPE = 4;
CHANGED_SCALE = 8;
CHANGED_TEXTURE = 16;
CHANGED_LINK = 32;
CHANGED_ALLOWED_DROP = 64;
CHANGED_OWNER = 128;
CHANGED_REGION = 256;
CHANGED_TELEPORT = 512;
CHANGED_REGION_RESTART = 1024;
CHANGED_REGION_START = 1024; //LL Changed the constant from CHANGED_REGION_RESTART
CHANGED_MEDIA = 2048;
CHANGED_ANIMATION = 16384;

_________________
No further support of any kind, for any of my materials. Use as/is whereis.
PLEASE UNSTICKY Any Stickied Posting by myself.


Top
 Profile  
 
 Post subject: Re: REFERENCE: change event values / constants
PostPosted: Tue Oct 26, 2010 3:04 pm 

Joined: Fri Jan 08, 2010 5:38 am
Posts: 33
Hello WhiteStar ..

While testing i found this out about following Constants:

2 & 16 -> do the same .. (CHANGED_COLOR = 2; / CHANGED_TEXTURE = 16;)
CHANGED_SCALE = 8; -> is not working
CHANGED_MEDIA = 2048; -> is not working
CHANGED_SHAPE = 4; -> is not working

I have filed a Mantis on this here:
http://opensimulator.org/mantis/view.php?id=5146

best regards
Wordfromthe Wise


Top
 Profile  
 
 Post subject: Re: REFERENCE: change event values / constants
PostPosted: Mon Dec 13, 2010 9:19 am 
Furious Typer

Joined: Mon Sep 27, 2010 7:12 am
Posts: 53
Just an additional comment re the changed() event:

A common use for this event trigger is to detect when someone sits down on a prim or stands up again. There is a bug in the code that results in the changed() event NOT being triggered when it has a current sit target = <0.0,0.0,0.0>, ZERO_ROTATION. There is no mention made of this bug in the SL scripting wiki in any of the relevant wiki articles so you won't find this documented in the changed() article or the CHANGED_LINK article; and while the llSitTarget article mentions that setting it to <0.0,0.0,0.0>,ZERO_ROTATION removes the sit target, it doesn't explicitly state that this results in the changed() event not being triggered when an avatar subsequently sits on it. I wasted a silly amount of time trying to debug an otherwise perfect script I wrote that didn't change the sit target to something other than the default null values.

Bottom line: if you want to use the changed() event to detect and avatar sitting down or standing back up again, you must change the sit target at some other point in the script prior to the point when you expect the avatar to sit down on it. Even setting it to <0.0,0.0,0.000001>, ZERO_ROTATION is enough top ensure that the changed() event triggers as expected.

If for some reason you absolutely must have the sit target set to NULL, there is another work-around for this bug: you can run a frequent (and therefore more resource-intensive) timer check to see how many prims are attached to the object using a comparison of the result of two prim-count functions. The llGetObjectPrimCount function doesn't include seated avatars in its count whereas the llGetNumberOfPrims function does, thus any difference in their counts *should* indicate that an avatar is sitting on the prim.

If you want to check this out for yourself, rez a prim and drop the following script in it. In its entry state only the the timer will notice and report it when you sit down on the prim or stand up again. If you touch the prim, both the changed() event and the timer will notice and report it to you. Touching the prim again will continue to toggle it back and forth between the two.

{L_CODE}:
vector currentSitTarget=ZERO_VECTOR;
integer targetFlag=FALSE;
key avatarID;
integer timerFlag=FALSE;

default
{
    state_entry()
    {
        llSitTarget(currentSitTarget,ZERO_ROTATION);
        llOwnerSay("Sit target now set to " + (string)currentSitTarget);
        llSetTimerEvent(0.5);
        llOwnerSay("Object prim count check reports " + llGetObjectPrimCount(llGetKey()));
        llOwnerSay("Number of prims check reports " + llGetNumberOfPrims());
    }
    changed(integer change)
    {
        if (change & CHANGED_LINK)
        {
            avatarID = llAvatarOnSitTarget();
            if (avatarID && avatarID!=NULL_KEY)
            {
                llOwnerSay(llKey2Name(avatarID) + " sat on me.");
            }
            else
            {
                llOwnerSay("The avatar stood up again.");
                avatarID = NULL_KEY;
            }
        }
    }
    touch_start(integer num_detected)
    {
        if (targetFlag)
        {
            currentSitTarget = ZERO_VECTOR;
            targetFlag=FALSE;
        }
        else
        {
            currentSitTarget = <0,0,0.000001>;
            targetFlag=TRUE;
        }
        llSitTarget(currentSitTarget,ZERO_ROTATION);
        llOwnerSay("Sit target now set to " + (string)currentSitTarget);
    }
    timer()
    {
        if (!timerFlag && llGetObjectPrimCount(llGetKey())!=llGetNumberOfPrims())
        {
            timerFlag=TRUE;
            llOwnerSay("Timer routine detected an avatar sitting down");
        }
        else if (timerFlag && llGetObjectPrimCount(llGetKey())==llGetNumberOfPrims())
        {
            timerFlag=FALSE;
            llOwnerSay("Timer routine detected an avatar standing up");
        }
    }
}




EDIT: This bug had been reported in Mantis months ago but left unattended so I bumped it again yesterday. I notice that someone has since looked at it and that a fix should be coming (presumably with the next code update)


Top
 Profile  
 
 Post subject: Re: REFERENCE: change event values / constants
PostPosted: Mon Apr 29, 2013 9:42 pm 
OSG Elite
User avatar

Joined: Wed Mar 11, 2009 3:57 pm
Posts: 444
PLEASE UNSTICKY THIS ASAP and Any other Stickied Posting by myself

_________________
No further support of any kind, for any of my materials. Use as/is whereis.
PLEASE UNSTICKY Any Stickied Posting by myself.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 4 posts ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net