Shihan Feiri Posted July 29, 2011 Share Posted July 29, 2011 How to corect write this if(llDetectedKey(0) != llGetOwner() && llGetObjectDesc()){...}where in object descripton is renter key Link to comment Share on other sites More sharing options...
Darkie Minotaur Posted July 29, 2011 Share Posted July 29, 2011 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 More sharing options...
Shihan Feiri Posted July 29, 2011 Author Share Posted July 29, 2011 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 More sharing options...
Fynn Emerald Posted July 29, 2011 Share Posted July 29, 2011 perhaps you mean: key toucher = llDetectedKey(0); if ( toucher != llGetOwner() && (string) toucher == llGetObjectDesc() ) { do something here } 1 Link to comment Share on other sites More sharing options...
Shihan Feiri Posted July 29, 2011 Author Share Posted July 29, 2011 yes, i think that can work. Let me try Link to comment Share on other sites More sharing options...
Shihan Feiri Posted July 29, 2011 Author Share Posted July 29, 2011 And Fynn, Welcome to forum Link to comment Share on other sites More sharing options...
Ela Talaj Posted July 29, 2011 Share Posted July 29, 2011 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 More sharing options...
Darkie Minotaur Posted July 29, 2011 Share Posted July 29, 2011 What Ela said in effect is: your code is far from beig nonesense - there are two things you got wrong: 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(); 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 More sharing options...
Innula Zenovka Posted July 29, 2011 Share Posted July 29, 2011 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 More sharing options...
Tabris Daxter Posted July 29, 2011 Share Posted July 29, 2011 @Shihan Feir see also RFC: single script multi room rental box. but i think that is where your trying to get it from Link to comment Share on other sites More sharing options...
Void Singer Posted July 30, 2011 Share Posted July 30, 2011 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 More sharing options...
Ela Talaj Posted July 31, 2011 Share Posted July 31, 2011 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 More sharing options...
Innula Zenovka Posted July 31, 2011 Share Posted July 31, 2011 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 More sharing options...
Void Singer Posted July 31, 2011 Share Posted July 31, 2011 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 More sharing options...
Recommended Posts
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