Jump to content

Definition


Shihan Feiri
 Share

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

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

Recommended Posts

I don't understand your question, really. Could you re-phrase it? A renter key is not a property of an object. I suspect that this script utilizes der object description to store the renter key. You find the object description in the edit window below the name. You can enter there what you want (well, basically) and red and set it in scripts usung llSet/llGetObjectDesc - and some other functions

Link to comment
Share on other sites

This is in touch event

if detected key is not owner and not renter  script say something

if detected key is owner and/or renter script do something else- give menu, for sample

so..

 

 touch_start(integer total_number){

owner=llGetOwner();

renter= llGetObjectDesc();

if(llDetectedKey(0)   !=  owner && renter)

{

llSay(0,"You are not alowed person to touch me ");

}

else

menu (sample)

}

Link to comment
Share on other sites

Basically what you wrote is a total nonsense :)

Assuming it compiles (a big question) llGetOwner() && llGetObjectDesc() always evaluates to TRUE so your condition becomes: if(llDetectedKey(0)   != TRUE) which in turn always evaluates to FALSE and whatever is in the brackets underneath it will never execute.

(We must remember that TRUE is anything that is not 0, not necessarily 1)

What you probably wanted to write would look like this:

if(llDetectedKey(0)   !=  llGetOwner() && llDetectedKey(0) != (key)llGetObjectDesc())

 

 

 

Link to comment
Share on other sites

What Ela said in effect is: your code is far from beig nonesense - there are two things you got wrong:

  1. the description is always a string - so if you need a key, you have to cast it into a key - so it would be:
    renter= (key)llGetObjectDesc();
  2. If you test value a against values b and c it's not a==b && c, but a == b && a == c
    In your case that would be
    if (llDetectedKey(0) != owner && llDetectedKey(0) != renter) {...}
Link to comment
Share on other sites

Just to be on the safe side, I'd cast renter as a key, thus:

 

key renter = (key)llGetObjectDesc();

 on the grounds I can never remember when you need to cast a string as a key and when you don't, and it's easier (and never wrong) always so to do than is it to try to remember when it does and doesn't matter.

Another way to do the test would be 

if(!~llListFindList([owner,renter],[llDetectedKey(0)])){	//neither the owner nor the renter}

 

Link to comment
Share on other sites


Innula Zenovka wrote:

Just to be on the safe side, I'd cast renter as a key, thus:

 
key renter = (key)llGetObjectDesc();

 on the grounds I can never remember when you need to cast a string as a key and when you don't, and it's easier (and never wrong) always so to do than is it to try to remember when it does and doesn't matter.

Another way to do the test would be 
if(!~llListFindList([owner,renter],[llDetectedKey(0)])){	//neither the owner nor the renter}

 

be careful with that last one... owner and renter need to be of key type for it to work

 

@Ela

LSL has comparison operators at a higher precedence than boolen ones, so the  comparison would be first.

Link to comment
Share on other sites

Sorry, I've no idea what you're trying to say. A conditional statement (comparison) evaluates to a boolean variable in any language; there is nothing else for it to evaluate to. The operators precedence in LSL is exactly the same as in ANSI C.

Link to comment
Share on other sites


Ela Talaj wrote:

Sorry, I've no idea what you're trying to say. A conditional statement (comparison) evaluates to a boolean variable in any language; there is nothing else for it to evaluate to. The operators precedence in LSL is exactly the same as in ANSI C.

I think what Void is saying -- and she's right, of course -- is that 

 

if(!~llListFindList([owner,renter],[llDetectedKey(0)])){	//neither the owner nor the renter}

 only works if owner and renter have both been explicitly cast as keys.   Otherwise the script doesn't know they're keys and thinks they're strings, so it will always return FALSE since llDetectedKey(0) is never going to be a string.    I've been caught by that before.

 

Link to comment
Share on other sites

if(llDetectedKey(0)  !=  llGetOwner() && llGetObjectDesc())

!= evaluates before && is what I was saying...

and not exactly the same as ansi C, as && and || are the most glaring example (equal precedence in LSL), and the RTL order of variable evaluation changes the behavior of increments, decrements, and assignments.

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4652 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...