JackRipper666 Posted December 30, 2012 Share Posted December 30, 2012 Hi guys I'm kinda puzzled by some code I been working on. I created some state entries that turn off an on physics that are to resemble cold breath on a cold night. So I type the commands /0 ColdBreath On and it turns it on then /0 ColdBreath Off and it turns it off. The problems I am having is it tends to turn it on only for a brief moment I see some breath and then its as if it turns its self off lol. But then I am curious if I wrote it right so I try the off command which is /0 ColdBreath Off. After I do this it does turn it off and it should go back to Default state but when I try to turn it back on it doesn't say anything. I put llSay in there to see what part of the code it's on. Seems like I can't get back to default state and at same time I can't get the physics to stay on. If anyone has time think you could look at this code for me see if you can help me out? key owner; default { state_entry() { llSetTimerEvent(2.7); } timer() { owner = llGetOwner(); llListen(0,"","",""); } on_rez(integer a){ owner = llGetOwner(); } listen(integer channel, string name, key id, string message) // listens to the channel. { if(llGetOwnerKey(id) == owner) if (message == "ColdBreath On") { llParticleSystem([PSYS_PART_MAX_AGE,0.8, PSYS_PART_FLAGS,1, PSYS_PART_START_COLOR, <1,1,1>, PSYS_PART_END_COLOR, <2,2,2>, PSYS_PART_START_SCALE,<0.1,0.1,0.1>, PSYS_PART_END_SCALE,<0.4,0.4,0.4>, PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_EXPLODE, PSYS_SRC_BURST_RATE,0.1, PSYS_SRC_ACCEL, 0.8 * llRot2Fwd(llGetRot()), PSYS_SRC_BURST_PART_COUNT,15, PSYS_SRC_BURST_RADIUS,0.02, PSYS_SRC_BURST_SPEED_MIN,0.0, PSYS_SRC_BURST_SPEED_MAX,0.2, PSYS_SRC_TARGET_KEY,llGetOwner(), PSYS_SRC_ANGLE_BEGIN,0.0, PSYS_SRC_ANGLE_END,0.0, PSYS_SRC_OMEGA, <0.2,0.2,0.2>, PSYS_SRC_MAX_AGE, 0.2, PSYS_SRC_TEXTURE, "8146459e-47a2-47ce-93d6-bac9359afa84", PSYS_PART_START_ALPHA, 0.3, PSYS_PART_END_ALPHA, 0.1 ]);llSay (0, "On"); } else if ( message == "ColdBreath Off") { state Off; } } } state Off { state_entry() { owner = llGetOwner(); llListen(0,"","","");llParticleSystem([]);llSay(0, "Off"); } listen(integer channel, string name, key id, string message) // listens to the channel. { if(llGetOwnerKey(id) == owner) if (message == "ColdBreath On") { state default; } } } Link to comment Share on other sites More sharing options...
Xiija Posted December 30, 2012 Share Posted December 30, 2012 no need for states or a timer mebbe? this is a small tweak, works on channel 1.... key owner;default{ state_entry() { owner = llGetOwner(); llListen(1,"","",""); } listen(integer channel, string name, key id, string message) // listens to the channel. { if(llGetOwnerKey(id) == owner) { if (message == "ColdBreath On") { llParticleSystem([PSYS_PART_MAX_AGE,4.0, PSYS_PART_FLAGS,1, PSYS_PART_START_COLOR, <1,1,1>, PSYS_PART_END_COLOR, <2,2,2>, PSYS_PART_START_SCALE,<0.1,0.1,0.1>, PSYS_PART_END_SCALE,<0.4,0.4,0.4>, PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_EXPLODE, PSYS_SRC_BURST_RATE,5.0, PSYS_SRC_ACCEL, 0.2 * llRot2Fwd(llGetRot()), PSYS_SRC_BURST_PART_COUNT,15, PSYS_SRC_BURST_RADIUS,0.02, PSYS_SRC_BURST_SPEED_MIN,0.0, PSYS_SRC_BURST_SPEED_MAX,0.2, PSYS_SRC_TARGET_KEY,llGetOwner(), PSYS_SRC_ANGLE_BEGIN,0.0, PSYS_SRC_ANGLE_END,0.0, PSYS_SRC_OMEGA, <0.2,0.2,0.2>, PSYS_SRC_MAX_AGE, 0.0, PSYS_SRC_TEXTURE, "8146459e-47a2-47ce-93d6-bac9359afa84", PSYS_PART_START_ALPHA, 0.3, PSYS_PART_END_ALPHA, 1.0 ]): llOwnerSay ( "On"); } else if ( message == "ColdBreath Off") { llParticleSystem([]); llOwnerSay( "Off"); } } }} 1 Link to comment Share on other sites More sharing options...
Innula Zenovka Posted December 30, 2012 Share Posted December 30, 2012 The reason, I think, that "it tends to turn it on only for a brief moment I see some breath and then its as if it turns its self off" is that you've said PSYS_PART_MAX_AGE,0.8, That tells it to turn off, for each person who sees it, after 0.8 seconds. 1 Link to comment Share on other sites More sharing options...
JackRipper666 Posted December 30, 2012 Author Share Posted December 30, 2012 Ah ok thanks guys I'm going to try this. And I see I made this more complicated then it has to be some how lol! Thanks again for the tweaks! Link to comment Share on other sites More sharing options...
JackRipper666 Posted December 30, 2012 Author Share Posted December 30, 2012 Yea you were right Innula some how my numbers got messed up and it was turning off with max age. An to fix my problem where once I turned it off it stop listening to me as I type commands I just added llResetScript(); to it and now I can keep going in a loop to turn it off an on lol! Thanks again! Link to comment Share on other sites More sharing options...
Rolig Loon Posted December 30, 2012 Share Posted December 30, 2012 I'm a little surprised nobody has pointed out that you should NEVER create an open llListen on the public chat channel for something like this. Your script will add a significant chat lag to the sim, because the servers will have to parse every single message that anyone says on channel 0 to match it against your script's filter. If you have to use a listen event to trigger your off/on switch, you should use a higher-numbered channel that is less likely to cause problems. Link to comment Share on other sites More sharing options...
JackRipper666 Posted December 30, 2012 Author Share Posted December 30, 2012 How high of a number Rolig? I started using /4 lol Link to comment Share on other sites More sharing options...
Rolig Loon Posted December 30, 2012 Share Posted December 30, 2012 How high? Well, anything above zero is an improvement, but the low integers are used so often by amateur scripters that they aren't much better. I don't like using listens for switches at all myself. When I have no other choice, I prefer using a number like 83 or 117 that is less likely to be in heavy use. The thing is, unless you plan to switch the device on and off a lot, it's just as easy to make it touch-activated, perhaps with a simple HUD button. Link to comment Share on other sites More sharing options...
JackRipper666 Posted December 30, 2012 Author Share Posted December 30, 2012 I'm definitely amateur when it comes to scripts/programming lol. My only understanding to turn off an on phyics or even make mesh objects like an avatars mouth move to a different position/expression is to use chat listener. I like using touch start default scripts and change them to commands I use to talk to the scripts in a mouth etc. I do get lag here an there which can break my illusions. Is there a better way then to do this? I'm not sure what you mean by touch activated with a hud button. I usually touch a button I make on a hud that has the touch start script in there and the listener scripts are in other parts to hear it and make it move. lol Link to comment Share on other sites More sharing options...
Rolig Loon Posted December 31, 2012 Share Posted December 31, 2012 JackRipper666 wrote: [....] I'm not sure what you mean by touch activated with a hud button. I usually touch a button I make on a hud that has the touch start script in there and the listener scripts are in other parts to hear it and make it move. lol That's exactly right. You can make a dirt simple HUD that is nothing more than a toggle switch. integer gON;default{ touch_start (integer num) { llWhisper(-14285714, (string)(gON = !gON)); }} And then let your device listen on channel -14285714. if ((integer)msg == 0) {//turn off}else if ((integer) msg == 1) {//turn on} Link to comment Share on other sites More sharing options...
JackRipper666 Posted December 31, 2012 Author Share Posted December 31, 2012 Ah ok I'll try this as well. Thanks! =) 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