Innula Zenovka Posted June 29, 2011 Share Posted June 29, 2011 I'm a bit confused with control events. What I've got, having studied the article in the LSL wiki, is integer up_left = CONTROL_ROT_LEFT|CONTROL_FWD; if((held & change) && (change & up_left)){ llOwnerSay("up left"); } I was expecting it to say "up left" only if I've pressed both the left and up arrow keys, but instead it's firing if I press either.What I want it do to is say "left" or "up", as appropriate, if I press one, and then "up left" if I press both. Where am I going wrong, please? Link to comment Share on other sites More sharing options...
Zena Juran Posted June 29, 2011 Share Posted June 29, 2011 you might try... integer up_left = CONTROL_ROT_LEFT|CONTROL_FWD;if((held & up_left) && (change & up_left)){ llOwnerSay("up left"); Link to comment Share on other sites More sharing options...
Void Singer Posted June 30, 2011 Share Posted June 30, 2011 it might help you to know how controls report... keydown = held:true, change:true keyheld = held:true, change:false keyup = held:false, change:true each key is a single bit in the control event, the bits positions match across the held and change variables. using bitwise AND (&) compares if particular bits (keys) are set to true or false. using logical AND (&&) checks if ANY bits are set. Link to comment Share on other sites More sharing options...
Kaluura Boa Posted June 30, 2011 Share Posted June 30, 2011 A bit of binary maths... integer up_left = CONTROL_ROT_LEFT|CONTROL_FWD;if ((held & change & up_left) == up_left){ llOwnerSay("up left");} Or more verbosely: if (((held & up_left) == up_left) && ((change & up_left) == up_left)) That will do the trick. Link to comment Share on other sites More sharing options...
Innula Zenovka Posted June 30, 2011 Author Share Posted June 30, 2011 Thanks, everyone. I finally, before I'd read all the replies, got it working with if((change) && (held == up_left)){ llOwnerSay("up left"); } Link to comment Share on other sites More sharing options...
Void Singer Posted July 1, 2011 Share Posted July 1, 2011 that's a good solution, but be aware that it will trigger only when just those two keys are held down, or when those keys are held down and third key is released. Kalura's will only triger if those two keys are held down at the same time (and controls trigger fast so it must be in the same frame) if you don't want them to be exclusive, and want to catch asynchronous presses ((change & up_left) && ((held & up_left) == up_left)) will be be more forgiving (at least one of the two changed, and both are now down) 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