llTakeControll how do you combining controls?
|
|
Prognastat Vellhi
Registered User
Join date: 30 Apr 2007
Posts: 16
|
11-28-2007 14:42
default { state_entry() { llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS); } run_time_permissions(integer perm) { if (perm & PERMISSION_TAKE_CONTROLS) { llTakeControls(CONTROL_UP | CONTROL_DOWN, TRUE, FALSE); } } control(key id, integer held, integer change) { // something happened to one of our controls if (held & CONTROL_LBUTTON) { llStartAnimation(); } if (change CONTROL_LBUTTON) { llStoptAnimation(); } } }
now in this script I want it to do
if (held & CONTROL_FWD) { llStartAnimation(); }
but it should only do that when the left mousebutton(CONTROL_LBUTTON) is held. COuld someone help me out on how I could get this to work?
|
|
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
|
11-28-2007 14:50
if you mean like hold fwd and LButtom you would do this default { state_entry() { llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS); }
run_time_permissions(integer perm) { if (perm & PERMISSION_TAKE_CONTROLS) { llTakeControls(CONTROL_UP | CONTROL_DOWN | CONTROL_FWD, TRUE, FALSE); // would need the CONTROL_FWD also added to even know it is sapossed to be taken conrol of } }
control(key id, integer held, integer change) { // something happened to one of our controls if ((held & CONTROL_LBUTTON) && (held & CONTROL_FWD))
// add a (( at the begining for combined control and && to say there is a second command after the end of control group you would need another )) kinda like in algibra ((link 1) all linked together with && ( link 2))
{ llStartAnimation(); } if (change CONTROL_LBUTTON) { llStoptAnimation(); } } }
im not 100% sure what you mean tho
|
|
Prognastat Vellhi
Registered User
Join date: 30 Apr 2007
Posts: 16
|
11-28-2007 14:55
thank you very much, it worked with a one small change. I'd been trying to get that to work for a whole day now.
default { state_entry() { llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS); }
run_time_permissions(integer perm) { if (perm & PERMISSION_TAKE_CONTROLS) { llTakeControls( CONTROL_DOWN | CONTROL_LBUTTON | CONTROL_ML_LBUTTON | CONTROL_FWD | CONTROL_LEFT | CONTROL_RIGHT | CONTROL_BACK | CONTROL_UP | CONTROL_ROT_RIGHT| CONTROL_ROT_LEFT , TRUE, TRUE); } }
control(key id, integer held, integer change) { // something happened to one of our controls if (held & CONTROL_FWD) { llStartAnimation(runanim); } if (change & CONTROL_FWD) { llStopAnimation(runanim); } if (held & CONTROL_DOWN) { llStartAnimation(ganim); } if (change & CONTROL_DOWN) { llStopAnimation(ganim); } if ((held & CONTROL_LBUTTON) && (pressed & CONTROL_UP)) { llStartAnimation(); } } }
in the llTakeControl I did TRUE, TRUE because I want the avatar to still work on regular inputs when mouse left button is not held however when LBUTTON, ML_LBUTTON and DOWN are held I want the av to be immobilized and only listen to the control input. Could someone help me out or give me a push in the right direction?
|
|
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
|
11-28-2007 15:55
From: Prognastat Vellhi in the llTakeControl I did TRUE, TRUE because I want the avatar to still work on regular inputs when mouse left button is not held however when LBUTTON, ML_LBUTTON and DOWN are held I want the av to be immobilized and only listen to the control input. Could someone help me out or give me a push in the right direction? Well, as the old saying goes, you can't have your cake and eat it, too; at least not with llTakeControls by itself. With it, you either pass them or you don't; there's no middle ground. HOWEVER, you can simulate stuff like you are talking about. If you want the client to still respond to the controls you take, you MUST pass the controls, otherwise, you have to simulate avatar movement with animations and llApplyImpulse. Not very pretty. On the other hand, you can still pass all controls so the client controls the movement, but you can immobilize the avatar (pretty much) via doing things like llMoveToTarget(llGetRootPosition(),0.01); or somesuch in an attachment. Bottom line is that it is a somewhat difficult workaround, because you can't conditionally take controls based on what ones are depressed at any time. Though, someone might suggest to reissue llTakeControls with different parameters, depending on what was depressed when, but that would be a-whole-nother can of worms.
|
|
Prognastat Vellhi
Registered User
Join date: 30 Apr 2007
Posts: 16
|
11-29-2007 13:05
I solved the problem by using two states, one in which it was TRUE, TRUE and one with TRUE, FALSE. It works fine now, thanks for the help though.
|
|
Cryas Tokhes
Great Googley Moogley...
Join date: 8 Feb 2006
Posts: 124
|
11-30-2007 14:12
looking at the llTakeControls ... the firt value is an integer with a value... each control has an assosiated value in bit sense..
integer desired_controls = CONTROL_DOWN | CONTROL_LBUTTON | CONTROL_ML_LBUTTON | CONTROL_FWD | CONTROL_LEFT | CONTROL_RIGHT | CONTROL_BACK | CONTROL_UP | CONTROL_ROT_RIGHT| CONTROL_ROT_LEFT; comment out the ones you dont want... llTakeControls(desired_controls,1,1); that should help out...
|
|
Jopsy Pendragon
Perpetual Outsider
Join date: 15 Jan 2004
Posts: 1,906
|
11-30-2007 15:59
Just keep in mind that for as long as a controls is HELD down, it will continue to generate events... so it'll be trying to start that animation over and over needlessly. May as well only try to start the animation when the control changes from "not-held" to "held". (and, likewise only attempt to stop the animation when the control goes from "held" to "not-held".) I was just tinkering with this yesterday and here's what I'm using to do this: control( key id, integer held, integer change ) { if ( held & change & CONTROL_FWD ) { // just pressed llStartAnimation( "my animation" ); } else if ( ~held & change & CONTROL_FWD ) { // just released llStopAnimation( "my animation" ); } }
_____________________
* The Particle Laboratory * - One of SecondLife's Oldest Learning Resources. Free particle, control and targetting scripts. Numerous in-depth visual demonstrations, and multiple sandbox areas. - Stop by and try out Jopsy's new "Porgan 1800" an advanced steampunk styled 'particle organ' and the new particle texture store!
|