Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Why does this?

Ginge Reymont
Registered User
Join date: 10 Oct 2005
Posts: 190
08-14-2006 13:49
Not return when I tp, it dosnt reply Tped. Is the CHANGED_TELEPORT used in manual teleport?
CODE

changed(integer change)
{
llSay(0,(string)change);// Returns 768
if (change == CHANGED_TELEPORT)
{
llSay(0,"Tped");
}



}
Azurei Ash
The Sticky!
Join date: 12 Jan 2006
Posts: 38
08-14-2006 14:17
It looks like you are getting not just one change happening, but two. Both CHANGED_TELEPORT (0x200) and CHANGED_REGION (0x100), together giving a decimal value of 768, as reported.

The solution, instead of using == to test for equivalency, use bitwise and (&;) to see if the bit you are looking for is set.

Thus your event becomes:

CODE
changed(integer change) 
{
llSay(0,(string)change);// Returns 768
if (change & CHANGED_TELEPORT)
{
llSay(0,"Tped");
}



}


And that will fire whenever they teleport. Note that you can teleport from one location to another location in the same region. If your event only needs to fire if they change regions, you might consider using CHANGED_REGION instead.

Testing for direct equivalency is rarely what you want when dealing with bitmasks, unless you know exactly what you want, so use bitwise logic.

~Az