Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Dissapearing Touch button.

a lost user
Join date: ?
Posts: ?
08-23-2005 23:36
I'm still new to scripting. Right now I'm trying to write two simple scripts.
One will that will activate a particle script when someone sits down and another that will just tigger an animation and whisper some text when the person touches the item.
(These are two different items btw)
But every code I write or adapt automatically greys out the touch button. Even when I use the touch event. What's going on?

--
sorry, I wrote the previous at 3am

To clear things up here are the scripts I'm using.

This one is a simple pill that will go away after touching (swallowing) but the touch button just dissapears.

CODE

//Pill

default
{
state_entry()
{
llWhisper(0, "Touch me to swallow");
}

touch_start(integer total_number)
{
llWhisper(0, "The pill dissolves on your tongue.");
llStartAnimation("hover"); //or flyslow or soft_land
llWhisper(0, "You feel so much better");
//
// I'd like to put in a mist in here somewhere?
//
llDie();
}
}


and this is the ball script that I tried to modify. All I want it to do is when someone sits on the ball, it mists. you sit but there is no mist.

CODE

// Particle Script 0.3
// Created by Ama Omega
// 10-10-2003

// Mask Flags - set to TRUE to enable
integer glow = TRUE; // Make the particles glow
integer bounce = FALSE; // Make particles bounce on Z plan of object
integer interpColor = TRUE; // Go from start to end color
integer interpSize = TRUE; // Go from start to end size
integer wind = FALSE; // Particles effected by wind
integer followSource = TRUE; // Particles follow the source
integer followVel = TRUE; // Particles turn to velocity direction

// Choose a pattern from the following:
// PSYS_SRC_PATTERN_EXPLODE
// PSYS_SRC_PATTERN_DROP
// PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY
// PSYS_SRC_PATTERN_ANGLE_CONE
// PSYS_SRC_PATTERN_ANGLE
integer pattern = PSYS_SRC_PATTERN_ANGLE_CONE;

// Select a target for particles to go towards
// "" for no target, "owner" will follow object owner
// and "self" will target this object
// or put the key of an object for particles to go to
key target = "self";
key avatar;
string Animation = "sit";
integer masterswitch = TRUE;
float base_alpha = 1.0;

// Particle paramaters
float age = 10; // Life of each particle
float maxSpeed = 2; // Max speed each particle is spit out at
float minSpeed = 1; // Min speed each particle is spit out at
string texture; // Texture used for particles, default used if blank
float startAlpha = 0.9; // Start alpha (transparency) value
float endAlpha = 0.1; // End alpha (transparency) value
vector startColor = <1,.5,.75>; // Start color of particles <R,G,B>
vector endColor = <1,.5,.75>; // End color of particles <R,G,B> (if interpColor == TRUE)
vector startSize = <2.0,2.0,2.0>; // Start size of particles
vector endSize = <0.1,0.1,0.1>; // End size of particles (if interpSize == TRUE)
vector push = <0,0,-1>; // Force pushed on particles

// System paramaters
float rate = .1; // How fast (rate) to emit particles
float radius = .9; // Radius to emit particles for BURST pattern
integer count = 999; // How many particles to emit per BURST
float outerAngle = 1.54; // Outer angle for all ANGLE patterns
float innerAngle = 1.55; // Inner angle for all ANGLE patterns
vector omega = <1,2,3>; // Rotation of ANGLE patterns around the source
float life = 60; // Life in seconds for the system to make particles

// Script variables
integer flags;

updateParticles()
{
llSitTarget(<0,0,0.5>,ZERO_ROTATION);
if (target == "owner") target = llGetOwner();
if (target == "self") target = llGetKey();
if (glow) flags = flags | PSYS_PART_EMISSIVE_MASK;
if (bounce) flags = flags | PSYS_PART_BOUNCE_MASK;
if (interpColor) flags = flags | PSYS_PART_INTERP_COLOR_MASK;
if (interpSize) flags = flags | PSYS_PART_INTERP_SCALE_MASK;
if (wind) flags = flags | PSYS_PART_WIND_MASK;
if (followSource) flags = flags | PSYS_PART_FOLLOW_SRC_MASK;
if (followVel) flags = flags | PSYS_PART_FOLLOW_VELOCITY_MASK;
if (target != "") flags = flags | PSYS_PART_TARGET_POS_MASK;

llParticleSystem([ PSYS_PART_MAX_AGE,age,
PSYS_PART_FLAGS,flags,
PSYS_PART_START_COLOR, startColor,
PSYS_PART_END_COLOR, endColor,
PSYS_PART_START_SCALE,startSize,
PSYS_PART_END_SCALE,endSize,
PSYS_SRC_PATTERN, pattern,
PSYS_SRC_BURST_RATE,rate,
PSYS_SRC_ACCEL, push,
PSYS_SRC_BURST_PART_COUNT,count,
PSYS_SRC_BURST_RADIUS,radius,
PSYS_SRC_BURST_SPEED_MIN,minSpeed,
PSYS_SRC_BURST_SPEED_MAX,maxSpeed,
PSYS_SRC_TARGET_KEY,target,
PSYS_SRC_INNERANGLE,innerAngle,
PSYS_SRC_OUTERANGLE,outerAngle,
PSYS_SRC_OMEGA, omega,
PSYS_SRC_MAX_AGE, life,
PSYS_SRC_TEXTURE, texture,
PSYS_PART_START_ALPHA, startAlpha,
PSYS_PART_END_ALPHA, endAlpha
]);
}

default
{
state_entry()
{
updateParticles();
}
touch_start(integer total_number)
{
updateParticles();
}
}

what logic am I missing? thanks for the help
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
08-24-2005 07:53
Is the pill a single prim? If it's multiple prims and the script isn't in the root prim, the touch menu option will only be active if your mouse is over the prim that the script is in.

For the mist, your object should be misting all the time. To activate it when someone sits on it, you need to remove the particle call from state_entry and touch_start, and put it in a changed event handler where you check for someone sitting. I think the code will look something like this:

CODE

default
{
state_entry()
{
llParticleSystem([]); // Turn off any particles it might be generating
llSitTarget(ZERO_VECTOR, ZERO_ROTATION); // Change this to set up the sit position. You need to set a sit target so you get notified when someone sits
}

changed(integer change)
{
if (change == CHANGE_LINK)
{
if (llAvatarOnSitTarget() != NULL_KEY)
{
// Someone sat down
activateParticles();
}
else
{
// Someone got up
llPArticleSystem([]);
}
}
}
}


... something like that. I haven't tested that code. If you're not getting any mist at all, try playing with the particle parameters to make sure you're getting something. For instance, set the color to red, the size large, alpha to 1 (i.e. not transparent), and the age to several seconds. That way you'll know if you're getting any particles at all. Then you can tweak them to look like mist. And set life to 0 so it runs 'forever' (i.e. until you tell it to stop). In your current particle script it'll stop making particles after 60 seconds. Maybe that's why you aren't seeing any.
a lost user
Join date: ?
Posts: ?
Thanks.
08-24-2005 09:54
I'll give that a try when I'm home from work. Quick question, will this stop misting when the person stands up? Just thought of that... ooops. :-)

As to the pill, it is one prim and the touch selection is greyed out. The weird thing is that in the three small scripts I've tried to write or adapt, all of them greyed-out the touch selection even when I have a touch event in the code.

This boggles my mind mostly because I'm so used to VB or something like that....
:-)

Any thing I'm missing?
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
08-24-2005 10:27
I've just tried your pill script in a single prim and it works just fine. Well mostly.

You need to ask for permission to animate an avatar, so llRequestPermissions() in your touch_start too and some run_time_permissions fun for you I guess.

It it's a single prim object I'm guessing that your script might not be running, that would stop it.

It seems unlikely, but are both scripts in the same prim? It's possible with two scripts with touch_starts() in the same prim they don't know which one to trigger and so they turn it off, I've not experimented like that and it seems unlikely but you never know (well not yet anyway, I will soon!)

Edit: Did the test, simple touch events in multiple scripts are all triggered.
a lost user
Join date: ?
Posts: ?
08-24-2005 11:52
Thanks for the tip. Ive got a lot of work ahead of Me when I get home! :-) (fun work though!)
These programs are all in separate prims. Just seems weird that the touch button dissapears in all three programs I'm trying to code or adapt. Then again, I don't have much experience with C++ type language. :-)
Thanks again. I'll post what happens. :-)
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
08-24-2005 16:43
From: Owner Maltese
Quick question, will this stop misting when the person stands up? Just thought of that... ooops. :-)


Yes.
a lost user
Join date: ?
Posts: ?
Thanks Ziggy
08-25-2005 04:16
Your scipt addedeum worked. I does give an error on the line "if (change == CHANGE_LINK)" that says "Error: Name not defined within scope", which I guess means that there is no subroutine called CHANGE_LINK in the program) but it works perfectly.

As to the pill routine - I'm still getting no touch button. Still plugging at it though. :-)

Actually - an update: The script ignores any settings I change. I guess until I clear out that error it keeps all the settings the same. Am I right?
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
08-25-2005 08:24
Sorry, that should be CHANGED_LINK. Left out the D. I have a hard time keeping these names straight in my head.

From: someone
As to the pill routine - I'm still getting no touch button. Still plugging at it though. :-)


I had that happen to me yesterday too. Reset the script which should have put it back in the state with the touch_start handler, but no touch button. Try Tools->Set scripts to not running followed by Tools->Set scripts running. That fixed it for me.
a lost user
Join date: ?
Posts: ?
08-25-2005 11:36
Thanks. I'll fix that when I'm home. Thank you all so much for your help.

As to the pill if I create a new prim for it, the touch button is there. I've found it vanishes after I've updated the script.

Weird...
Jamie Marlin
Ought to be working....
Join date: 13 May 2005
Posts: 43
08-25-2005 12:44
I know this is probably a stupid question... but is there still an edit window open for the object in question? I believe that touch is greyed out when an edit window is open.
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
08-25-2005 13:10
Actually it isn't. The edit window overrides touching directly (the cursor assumes you're going to want to edit the thing you touch), but right-clicking still gives you the touch option.
a lost user
Join date: ?
Posts: ?
08-25-2005 19:04
It's still not working. :-( When someone sits on it, it'll mist for a short time and then stop. Barely ten seconds.

Here's the whole program.
CODE

// Particle Script 0.3
// Created by Ama Omega
// 10-10-2003

// Mask Flags - set to TRUE to enable
integer glow = TRUE; // Make the particles glow
integer bounce = FALSE; // Make particles bounce on Z plan of object
integer interpColor = TRUE; // Go from start to end color
integer interpSize = TRUE; // Go from start to end size
integer wind = FALSE; // Particles effected by wind
integer followSource = TRUE; // Particles follow the source
integer followVel = TRUE; // Particles turn to velocity direction

// Choose a pattern from the following:
// PSYS_SRC_PATTERN_EXPLODE
// PSYS_SRC_PATTERN_DROP
// PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY
// PSYS_SRC_PATTERN_ANGLE_CONE
// PSYS_SRC_PATTERN_ANGLE
integer pattern = PSYS_SRC_PATTERN_ANGLE_CONE;

// Select a target for particles to go towards
// "" for no target, "owner" will follow object owner
// and "self" will target this object
// or put the key of an object for particles to go to
key target = "self";

// Particle paramaters
float age = 10; // Life of each particle
float maxSpeed = 2; // Max speed each particle is spit out at
float minSpeed = 1; // Min speed each particle is spit out at
string texture; // Texture used for particles, default used if blank
float startAlpha = 0.9; // Start alpha (transparency) value
float endAlpha = 0.1; // End alpha (transparency) value
vector startColor = <1,.5,.75>; // Start color of particles <R,G,B>
vector endColor = <1,.5,.75>; // End color of particles <R,G,B> (if interpColor == TRUE)
vector startSize = <2.0,2.0,2.0>; // Start size of particles
vector endSize = <0.1,0.1,0.1>; // End size of particles (if interpSize == TRUE)
vector push = <0,0,-1>; // Force pushed on particles

// System paramaters
float rate = .1; // How fast (rate) to emit particles
float radius = .9; // Radius to emit particles for BURST pattern
integer count = 999; // How many particles to emit per BURST
float outerAngle = 1.54; // Outer angle for all ANGLE patterns
float innerAngle = 1.55; // Inner angle for all ANGLE patterns
vector omega = <1,2,3>; // Rotation of ANGLE patterns around the source
float life = 0; // Life in seconds for the system to make particles

// Script variables
integer flags;

updateParticles()
{
if (target == "owner") target = llGetOwner();
if (target == "self") target = llGetKey();
if (glow) flags = flags | PSYS_PART_EMISSIVE_MASK;
if (bounce) flags = flags | PSYS_PART_BOUNCE_MASK;
if (interpColor) flags = flags | PSYS_PART_INTERP_COLOR_MASK;
if (interpSize) flags = flags | PSYS_PART_INTERP_SCALE_MASK;
if (wind) flags = flags | PSYS_PART_WIND_MASK;
if (followSource) flags = flags | PSYS_PART_FOLLOW_SRC_MASK;
if (followVel) flags = flags | PSYS_PART_FOLLOW_VELOCITY_MASK;
if (target != "") flags = flags | PSYS_PART_TARGET_POS_MASK;

llParticleSystem([ PSYS_PART_MAX_AGE,age,
PSYS_PART_FLAGS,flags,
PSYS_PART_START_COLOR, startColor,
PSYS_PART_END_COLOR, endColor,
PSYS_PART_START_SCALE,startSize,
PSYS_PART_END_SCALE,endSize,
PSYS_SRC_PATTERN, pattern,
PSYS_SRC_BURST_RATE,rate,
PSYS_SRC_ACCEL, push,
PSYS_SRC_BURST_PART_COUNT,count,
PSYS_SRC_BURST_RADIUS,radius,
PSYS_SRC_BURST_SPEED_MIN,minSpeed,
PSYS_SRC_BURST_SPEED_MAX,maxSpeed,
PSYS_SRC_TARGET_KEY,target,
PSYS_SRC_INNERANGLE,innerAngle,
PSYS_SRC_OUTERANGLE,outerAngle,
PSYS_SRC_OMEGA, omega,
PSYS_SRC_MAX_AGE, life,
PSYS_SRC_TEXTURE, texture,
PSYS_PART_START_ALPHA, startAlpha,
PSYS_PART_END_ALPHA, endAlpha
]);
}

default
{
state_entry()
{
llParticleSystem([]); // Turn off any particles it might be generating
llSitTarget(ZERO_VECTOR, ZERO_ROTATION); // Change this to set up the sit position. You need to set a sit target so you get notified when someone sits
}

changed(integer change)
{
if (change == CHANGED_LINK)
{
if (llAvatarOnSitTarget() != NULL_KEY)
{
// Someone sat down
updateParticles();
}
else
{
// Someone got up
llParticleSystem([]);
}
}
}
}

Now, I've done programming before but this language leaves me messed up.
I apperciate the help and I'm sorry I have calling for help, but I really need this working.
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
08-25-2005 19:11
Main thing: do NOT emit 999 particles per burst. This is not the maximum number of particles that the system will emit, this is how many particles it emits PER BURST. This would result in almost a hundred thousand particles, but SL chokes it before that. That's probably why you stop seeing particles. (The default maximum particle count is 4096).

Also, learn to use the
CODE
 tags. We will all love you for it.

If you're posting particles to the forums, my script might be a better thing to use. It's much shorter.
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
08-25-2005 19:12
The sit target can't be ZERO_VECTOR and ZERO_ROTATION, that turns off the sit target. Use any nonzero vector.

You may want to explicitely check to see if the change has resulted in llAvatarOnSitTarget() returning NULL_KEY before turning off particles. Personally, I always track if there's currently a sitter by storing the UUID (key) so I can filter out other link changes easier.

Use llOwnerSay() to track what your events and decision trees are up to, also.
_____________________
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
08-25-2005 19:14
That might do it as well :)
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
08-25-2005 19:15
Ah, thanks for catching that. I shouldn't post stuff I haven't done :) And that's very good advice about tracking the sitting avatar too.
a lost user
Join date: ?
Posts: ?
08-26-2005 03:56
From: someone
Also, learn to use the
CODE
 tags. We will all love you for it. 


Well, at least I fixed the php problem. One thing I like is to be loved. :-)

You said you had an easier, shorter script. Where do I find it?