Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Bitwise question

Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
10-19-2009 19:09
I can never really get my head round bitwise operators, I fear.

What's the best way of testing "if a is true and b is false"? I'm particularly interested at the moment in knowing if AGENT_IN_AIR is true but AGENT_FLYING is false, but knowing the best way to do this in general would, of course, be ever so helpful.
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
10-19-2009 19:47
From: Innula Zenovka
What's the best way of testing "if a is true and b is false"?

That'd be...

if (a && !b)

...or, if it's easier to read...

if (a == TRUE && b == FALSE)

...or even...

if ((a) && (!b))

edit: and...

integer flags = llGetAgentInfo (id);
if (flags & AGENT_IN_AIR != 0 && flags & AGENT_FLYING == 0)

...is the easiest-reading way to do it, IMO.
_____________________
Sick of sims locking up every time somebody TPs in? Vote for SVC-3895!!!
- Go here: https://jira.secondlife.com/browse/SVC-3895
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
10-19-2009 20:01
From: Sindy Tsure


integer flags = llGetAgentInfo (id);
if (flags & AGENT_IN_AIR != 0 && flags & AGENT_FLYING == 0)



i'm not in world to check, but i'm pretty sure that's how the zhao 2 checks it so it knows whether to play a flying animation or a hovering animation. how does it check for falling though?
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
10-19-2009 20:23
Er.. I think if you're in the air and you're not flying, you're falling.. Dunno - I'm not in-world either..
_____________________
Sick of sims locking up every time somebody TPs in? Vote for SVC-3895!!!
- Go here: https://jira.secondlife.com/browse/SVC-3895
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
10-19-2009 21:15
From: Sindy Tsure
Er.. I think if you're in the air and you're not flying, you're falling.. Dunno - I'm not in-world either..

not if you're hovering, i guess if you're not moving and your in the air, then you're hovering, and if you're in the air and moving, but AGENT_FLYING == FALSE then you're falling?
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Pete Littlebird
Registered User
Join date: 30 Sep 2009
Posts: 44
10-20-2009 01:02
llGetAnimation returns the animation state ("Standing", "Falling Down", "Flying", Hovering", etc.) rather than the actual animation(s) being played, and may be useful here.
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
10-20-2009 04:36
From: Pete Littlebird
llGetAnimation returns the animation state ("Standing", "Falling Down", "Flying", Hovering", etc.) rather than the actual animation(s) being played, and may be useful here.
Indeed it does, which I didn't realise until recently.

Because, for what I'm trying to do, all I need to test is if I'm in the air and not flying, I was hoping there was a neater way than saying
CODE
if(llGetAgentInfo(id)&AGENT_IN_AIR){
if(llGetAnimation(id)!="Flying"){ //
}
}
and Sindy has shown me there is. Thank you so much.