Ruthven Ravenhurst Posted April 6, 2016 Share Posted April 6, 2016 I have this script I'm working on, and trying to add security features, so that the owner/group members can set the security. Anyways, I can't figure out why it's not giving me a dialog when I click it. Here is the touch event (Don't want to post the whole script as it's something I plan to sell probably). Maybe I have the logic wrong somewhere? I've been looking at it and working on it for hours, and need a second+ set of eyes to look at it for me. touch_start(integer num) { key toucher = llDetectedKey(0); templist = main; tempsectext = ""; if(security == "Public" && toucher != llGetOwner() && llDetectedGroup(0) == FALSE) { maindialog(toucher); } else if(security == "Owner" && toucher != llGetOwner()| security == "Group" && llDetectedGroup(0) == FALSE) { string grouptext = ""; if(security == "Group" && llDetectedGroup(0) == FALSE) { grouptext = "If you are a group member, you must have the group tag active for " + groupName + "\n\n"; } llDialog(toucher, grouptext + "Click button to turn " + onoff +".",[onoff, "Exit"],chan); } else if(toucher == llGetOwner() | llDetectedGroup(0) == TRUE && security == "Group") { templist += sec; tempsectext = sectext; maindialog(toucher); } } Link to comment Share on other sites More sharing options...
Rolig Loon Posted April 6, 2016 Share Posted April 6, 2016 It could be a number of things, including not having opening a llListen on your dialog channel, but I suspect that the problem is in your complicated if statement: else if(security == "Owner" && toucher != llGetOwner() security == "Group" && llDetectedGroup(0) == FALSE) Notice that your OR is a bitwise OR, not a logical one. You'll get the wrong anwser from that comparison. Aside from that, which I really think is the problem, you leave open the possibility of ambiguity if you don't put parentheses around the comparisons that you want to consider first. I think what you intended was something more like else if( (security == "Owner" && toucher != llGetOwner()) || (security == "Group" && llDetectedGroup(0) == FALSE) ) 1 Link to comment Share on other sites More sharing options...
Ruthven Ravenhurst Posted April 6, 2016 Author Share Posted April 6, 2016 Thank you Rolig! Yes, I have a listener already opened in the state_entry. It was the parenthesis that I was missing. Now I just need someone to help me test the group/public touches. Link to comment Share on other sites More sharing options...
Ron Khondji Posted April 6, 2016 Share Posted April 6, 2016 That's where alts come in handy 1 Link to comment Share on other sites More sharing options...
Ruthven Ravenhurst Posted April 9, 2016 Author Share Posted April 9, 2016 Hmm, so I logged in with my alt to test it, and it seems I'm still having trouble with the logic, not sure why. Even on my main avatar, if I set it to group, and have a different group active than the object, it gives me the non-owner dialog, but the touch event is supposed to always allow the owner the main dialog, no matter the group. touch_start(integer num) { llResetTime(); llListenRemove(listener); key toucher = llDetectedKey(0); chan = (integer)llFrand(-100000)-1000; listener = llListen(chan,"",toucher,""); active = TRUE; templist = main; tempsectext1 = ""; if((security == "Public") && (toucher != llGetOwner()) && (llDetectedGroup(0) == FALSE)) { maindialog(toucher); } else if((security == "Owner" && toucher != llGetOwner())|( security == "Group" && llDetectedGroup(0) == FALSE)) { string grouptext = ""; if(security == "Group" && llDetectedGroup(0) == FALSE) { grouptext = "If you are a group member, you must have the group tag active"; } llDialog(toucher, grouptext + "Click button to turn " + onoff +".",[onoff, "Exit"],chan); } else if((toucher == llGetOwner())| (llDetectedGroup(0) == TRUE && security == "Group")) { templist += sec; tempsectext1 = sectext1 + security; tempsectext1 +="\n"; maindialog(toucher); } } Link to comment Share on other sites More sharing options...
Ruthven Ravenhurst Posted April 9, 2016 Author Share Posted April 9, 2016 oops, nevermind, didn't notice the (verticle bar?, what is that symbol called?) was double in your version, will try that and hope it works touch_start(integer num) { llResetTime(); llListenRemove(listener); key toucher = llDetectedKey(0); chan = (integer)llFrand(-100000)-1000; listener = llListen(chan,"",toucher,""); active = TRUE; templist = main; tempsectext1 = ""; if((security == "Public") && (toucher != llGetOwner()) && (llDetectedGroup(0) == FALSE)) { maindialog(toucher); } else if((security == "Owner" && toucher != llGetOwner())( security == "Group" && llDetectedGroup(0) == FALSE)) { string grouptext = ""; if(security == "Group" && llDetectedGroup(0) == FALSE) { grouptext = "If you are a group member, you must have the group tag active"; } llDialog(toucher, grouptext + "Click button to turn " + onoff +".",[onoff, "Exit"],chan); } else if((toucher == llGetOwner()) (llDetectedGroup(0) == TRUE && security == "Group")) { templist += sec; tempsectext1 = sectext1 + security; tempsectext1 +="\n"; maindialog(toucher); } } Link to comment Share on other sites More sharing options...
Ruthven Ravenhurst Posted April 9, 2016 Author Share Posted April 9, 2016 Nope, still not quite right, which is odd. I have it start out in "Public" mode, if I switch it from that to something else, it works correctly with my alt, but if I switch it back to "Public", no dialog comes up for my alt, not even the limited menu that's supposed to come up for non-group/owner. The reason I want it to check for owner/group member in public mode is because there are additional buttons that I don't want shown in the public dialog Link to comment Share on other sites More sharing options...
Madelaine McMasters Posted April 9, 2016 Share Posted April 9, 2016 Ruthven Willenov wrote: oops, nevermind, didn't notice the (verticle bar?, what is that symbol called?) was double in your version, will try that and hope it works touch_start(integer num) { llResetTime(); llListenRemove(listener); key toucher = llDetectedKey(0); chan = (integer)llFrand(-100000)-1000; listener = llListen(chan,"",toucher,""); active = TRUE; templist = main; tempsectext1 = ""; if((security == "Public") && (toucher != llGetOwner()) && (llDetectedGroup(0) == FALSE)) { maindialog(toucher); } else if((security == "Owner" && toucher != llGetOwner())( security == "Group" && llDetectedGroup(0) == FALSE)) { string grouptext = ""; if(security == "Group" && llDetectedGroup(0) == FALSE) { grouptext = "If you are a group member, you must have the group tag active"; } llDialog(toucher, grouptext + "Click button to turn " + onoff +".",[onoff, "Exit"],chan); } else if((toucher == llGetOwner()) (llDetectedGroup(0) == TRUE && security == "Group")) { templist += sec; tempsectext1 = sectext1 + security; tempsectext1 +="\n"; maindialog(toucher); } } The vertical bar has too many names to mention here. In LSL and many other programming languages, a single vertical bar performs the "bitwise or" of the operands on either side of it. That's a logical operation on the individual bits inside the operands and is not what you want in your code. A double vertical bar performs the "logical or" of the truth (nonzero-ness) of the two operands on either side of it. So if you want something to happen if either of two things is true, you'd write... a || b ... which will be true (non-zero) if either a or b is true (non-zero) and false (zero) if both of them are false (zero). In most languages, the result of such true/false operations are zero (false) and one (true). It's probably better to think of zero as being the same as false and anything else as being the same as true. Zero is a lot more special than one! If you don't find that explanation sufficiently confusing, let me know! Link to comment Share on other sites More sharing options...
Rolig Loon Posted April 9, 2016 Share Posted April 9, 2016 That "double bar" was the main point of my response before. When you use one "bar" -- really a "pipe" -- it's a bitwise OR, which is not wht you want to do. You want a logical OR, which is || . As far as the rest of it is concerned, I was only guessing at what you wanted to do. Think of your restrictions from the top down. The owner gets the group menu and so does any group member who's wearing a tag, if security == group. Anyone else gets a public menu. So: if (llGetOwner() == toucher) { // group menu } else if (security == "Group") { if ( !llSameGroup(llDetectedKey(0)) ) { llSay(0, "Wear your group tag!"); // Public menu } else { //Group menu } } else { // Public menu } Link to comment Share on other sites More sharing options...
Ruthven Ravenhurst Posted April 9, 2016 Author Share Posted April 9, 2016 No, I understood it very well. Just trying to get my brain back into scripting again, as it's been a while. I did modify the touch event some more, as I was still having trouble getting it to give a dialog in some security instances. I guess I had it a little jumbled with the different tests, so I re-wrote it testing for each security setting, then against the llDetectedKey or llDetectedGroup touch_start(integer num) { llResetTime();//because part of the script triggers a timer, and within that timer I will remove the listen if more than 20 seconds has passed without activity llListenRemove(listener); key toucher = llDetectedKey(0); chan = (integer)llFrand(-100000)-1000; listener = llListen(chan,"",toucher,""); active = TRUE; templist = main;//resets main menu list and text in case toucher is not an admin tempsectext1 = ""; if(security == "Public") { if(toucher == llGetOwner() || llDetectedGroup(0)) { templist += sec;//adds admin only buttons and text tempsectext1 = sectext1 + security +"\n"; maindialog(toucher); } else{maindialog(toucher);} } else if (security == "Owner") { if(toucher == llGetOwner()) { templist += sec; tempsectext1 = sectext1 + security +"\n"; maindialog(toucher); } else { llDialog(toucher, "Click button to turn " + onoff +".",[onoff, "Exit"],chan); } } else if(security == "Group") { if((toucher == llGetOwner())|| llDetectedGroup(0)) { templist += sec; tempsectext1 = sectext1 + security +"\n"; maindialog(toucher); } else { llDialog(toucher, grouptext + "Click button to turn " + onoff +".",[onoff, "Exit"],chan); } } } Link to comment Share on other sites More sharing options...
Ruthven Ravenhurst Posted April 9, 2016 Author Share Posted April 9, 2016 Thanks, yeah I had it kind of messy, re-wrote it, not too far off from your solution lol. Guess that's what I was going for before, but jumbled up with too many tests. Link to comment Share on other sites More sharing options...
Madelaine McMasters Posted April 9, 2016 Share Posted April 9, 2016 Without closely examining the logic, that looks better, or at least easier to follow. What happens if "security" isn't any of the values you're testing against? You don't show that part of the script, but it's important to either handle every possible value of something, or ensure something can only have certain values. I usually try to do both in my code. So I'd have written... if(security == "Public"){ do public stuff} else if (security == "Owner"){do owner stuff} else if (security == "Group"){do group stuff} else { set security to Owner (or whatever is appropriate) and perhaps throw an error message } Link to comment Share on other sites More sharing options...
Ruthven Ravenhurst Posted April 10, 2016 Author Share Posted April 10, 2016 I have it starting out as "Public". It is changed via dialog menu. It will only be able to be, Public, Owner, or Group. Only group or owner are allowed to change it, though I do need to figure out some more logic to make it so that group members can change settings, but not security part, guess I could leave the security part for only the owner? Link to comment Share on other sites More sharing options...
Ruthven Ravenhurst Posted April 10, 2016 Author Share Posted April 10, 2016 If it is set to "Owner", all others can only turn the system on and off via dialog "Group", group members with active tags can access same menu as owner, all others get On/off menu Link to comment Share on other sites More sharing options...
Rolig Loon Posted April 10, 2016 Share Posted April 10, 2016 Now that's you've had all the fun of writing this -- it was fun, wasn't it? -- have you taken a look at my Generic Whitelist script in the library? 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