Shiro Neximus Posted May 1, 2016 Share Posted May 1, 2016 I'm wondering if there is a better way for 'state' (not in a script sense) detection, for example I want to make particles happen when an avatar is in a state of flight, and to stop when flight stops. The thing is, the way I have it sounds inefficient, slow, and script intensive, where it basically checks every 1 second if an avatar is flying. integer flying;default{ state_entry() {; llSetColor(<1,1,0>,ALL_SIDES); llSleep(1); flying = llGetAgentInfo(llGetOwner()); if(flying & AGENT_FLYING) state flying; if(flying & ~AGENT_FLYING); state notflying; }}state flying{ state_entry() { llSetColor(<0,1,0>, ALL_SIDES); llSay(0, "Flying"); llSleep(1); flying = llGetAgentInfo(llGetOwner()); if(flying & AGENT_FLYING) state default; if(flying & ~AGENT_FLYING); state notflying;}}state notflying{ state_entry() { llSetColor(<1,0,0>, ALL_SIDES); llSay(0, "Not Flying"); llSleep(1); flying = llGetAgentInfo(llGetOwner()); if(flying & AGENT_FLYING) state flying; if(flying & ~AGENT_FLYING); state default;}} Link to comment Share on other sites More sharing options...
Rolig Loon Posted May 1, 2016 Share Posted May 1, 2016 That's basically how it's done by AOs and similar devices. Link to comment Share on other sites More sharing options...
Madelaine McMasters Posted May 1, 2016 Share Posted May 1, 2016 Hi Shiro, Could you use "moving_start" and "moving_end" events to trigger llGetAgentInfo()? I don't think you can start/stop flying without starting/stopping motion, but I'm not sure. I also don't know if hovering looks like motion to an attachment. If it doesn't, you also have an easy way to turn particles off (or alter their appearance) when hovering. Link to comment Share on other sites More sharing options...
Innula Zenovka Posted May 1, 2016 Share Posted May 1, 2016 I don't think you need several states. I would keep it to one state and check things in a timer event, firing maybe once a second. So, the basic structure of the timer event is something like this: timer() { if(llGetAgentInfo(llGetOwner())&AGENT_FLYING) { //do something } else { //do something else } } However, since you probably actually want to do stuff when someone starts or stops flying, you might want to consider this structure: integer isFlying;default{ [...] timer() { integer int = llGetAgentInfo(llGetOwner()) & AGENT_FLYING); //am I flying if(!isFlying) //if I was not flying last time we looked { if(int)//but I am now { isFlying = TRUE; //make a note of the fact I'm flying //and do something -- turn on the particles or whatever } } else if (isFlying) { //if I was flying last time if !(int)//but I am no longer flying { isFlying = FALSE;//make a note I am not flying //and do something else, like turning off the particles } } }} I'd also suggest you consider testing llGetAnimation rather than llGetAgentInfo. There's absolutely nothing wrong with using llGetAgentInfo, and I simply mention llGetAnimation because people often forget about it and and I often find it easier to use than llGetAgentInfo because I can focus more narrowly on the avatar's actual animation state. 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