Page 1 of 1

no sitting avatar does not read as false

Posted: Wed May 20, 2020 2:17 am
by Kru Ruk
(Sorry for the less than clear subject line.)

Here's the issue.
I am porting many scripts I have written elsewhere into Kitely.
I ran into a problem with detecting when the avatar stands up.

Code: Select all

            key sittingID = llAvatarOnSitTarget();
            llOwnerSay("sittingID " + (string) sittingID);
            if ((string) sittingID == NULL_KEY) {
                llOwnerSay("Is null key");
                if (sittingID) {
                    llOwnerSay("id did not read as false");
                if (sittingID) {
                    llOwnerSay("normal check for no avatar sitting");
                if ((key)NULL_KEY) {
                    llOwnerSay("weird check is still true.");
Here is the output from the experiment:
[19:08] object: sittingID 00000000-0000-0000-0000-000000000000
[19:08] object: Is null key
[19:08] object: id did not read as false
[19:08] object: normal check for no avatar sitting. THis should have been false
[19:08] object: weird check is still true.

The first line of output is expected for an avatar that just stood up. There is not avataronsit
The next line of out put is captured by my kluged test. Almost all other scripts just use if(av) expecting the 00000 thing to calculate as false.
But, when I do that standard if check it doesn't work. It still evaluates as true.
I then tried casting the NULL_KEY to key and found it also does not evaluate as false.

This is a new world in Kitely. Is there an owner setting that effects how NULL_KEY is evaluated?

I'm sure I am doing something extremely silly in the code.
I missed a turn and have entered into the Twilight Zone. Any clues would be appreciated.

Re: no sitting avatar does not read as false

Posted: Wed May 20, 2020 11:33 am
by Ilan Tochner
Hi Kru,

Try this:

Code: Select all

if (sittingID == NULL_KEY)

Re: no sitting avatar does not read as false

Posted: Wed May 20, 2020 8:56 pm
by John Mela
A patch was submitted to fix this a while ago here:

but it never made it to the main branch. It's a difficult one because it calls into question the whole nature of typing in LSL. My own opinion is that treating key values as strings is flawed design by Linden Lab (they should be integers), but we have to live with the legacy of that decision, and here we're seeing the results of that mistake back in 2001 or whenever.

So I agree with Ilan's recommendation, even if it might seem counter-intuitive (and incompatible with SL's behaviour).

Re: no sitting avatar does not read as false

Posted: Thu May 21, 2020 3:15 am
by Kru Ruk
Thanks for the replies.
I was just looking for a little clarity.
There were so many opensim scripts using the code fragment:

Code: Select all

key av = llAvatarOnSitTarget();
if (av) {
	// avatar is sitting do something
} else {
	// avatar just stood up, do something
It felt weird that so many people were using a code solution in published scripts that just plain fail in opensim.
So I wanted to double check.

I respect the workaround as a good one and add that to the list of stuff to do when migrating a script from SL to the world :)

Thanks again.
Much appreciated.