Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Noob script question

ahkenatan Grommet
The lovable old Primosaur
Join date: 11 Jan 2005
Posts: 193
01-30-2008 19:45
Hello all,
I have a menu script that I incorporated buttons in to turn on and turn off an exhaust script(particles). Of course it doesn't work. I'm fairly sure the problem lies with my re-arranging the script at the bottom of the particle script.
I am going to post what I have at the end of Eltee's particle script.Bear in mind I have no clue what I am doing but I am trying so don't laugh too hard at my hack job. Oddly enough it compiled successfully but I know that means nothing really.

Any help would be much appreciated. If more info is needed I will glady provide it.

CODE

default {

state_entry()
{
llListen(-14,"","","");
}

on_rez(integer parameter)
{
llListen(-14,"","","");
}

listen(integer channel,string name,key id, string message)
{

if (llGetOwnerKey(id) == llGetOwner())
{
running=TRUE;
llSetText("", <0.0, 1.0, 0.0>, 0.5);
setParticles();
}

else if (message == "Exhaust off")
{
llParticleSystem([]);
}
}
}
CODE
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-31-2008 01:28
the way you have it set up, it checks if the message came from the owner or one of their items, and if so, it starts the particles...

if it's not the owner or one of their objects AND the message is 'Exhaust off' then it turns off...

so the only person that can turn it off is someone who is NOT the owner, and knows the right words.

you are also listening on a negative channel, so no av can naturally speak on this channel.

assuming you want to keep the negative channel, your listen would work better something like this

CODE

listen( integer vIntNull, string vStrNull, key vKeySpeaker, string vStrHeard ){
if (llGetOwnerKey( vKeySpeaker) == llGetOwner()){
if ("Exhaust off" == vStrHeard){
llParticleSystem( [] );
}else{
running=TRUE; //-- dunno what this does, but nothing is setting false in this code
llSetText("", <0.0, 1.0, 0.0>, 0.5); //-- again nothing changes this, I suspect it's to trigger a full prim update, which shouldn't be necessary when setting the particles
setParticles(); //-- I'm guessing this calls some particle setup not included above
}
}
}
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
01-31-2008 01:40
From: ahkenatan Grommet


CODE

default {

state_entry()
{
llListen(-14,"","","");
}

on_rez(integer parameter)
{
llListen(-14,"","","");
}

listen(integer channel,string name,key id, string message)
{

if (llGetOwnerKey(id) == llGetOwner())
{
running=TRUE;
llSetText("", <0.0, 1.0, 0.0>, 0.5);
setParticles();
}

else if (message == "Exhaust off")
{
llParticleSystem([]);
}
}
}
CODE


I guess the object is listening to commands from another object? (since you set a negative channel, I assume this is the case). If it should listen to a chat command, you can't set a negative channel, as these are reserved for objects.

Is the parameter «running» set as a global variable?

Try to enter a llOwnerSay() into the listen-event to see whether you're getting the right id and the right message.

Also try to find out, whether there's no space after "Exhaust off" by adding

else if(llStringTrim(message, STRING_TRIM) == "Exhaust off";) { ...
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
01-31-2008 01:43
damn - you're right about the else if statement, Void - totally slipped my attention... :)
ahkenatan Grommet
The lovable old Primosaur
Join date: 11 Jan 2005
Posts: 193
02-01-2008 17:53
Thank you very much for the responses. I must admit I am still somewhat clueless about whats going on however looking at what Void said I reworked the script. Here's a better description of what I'm doing. I have a prim with a menu script in it linked to a prim with a particle script. In the menu script I have this line and another to turn off.on the script:
CODE

if(message == "Exhaust on")
{
llMessageLinked(LINK_SET,0,"Exhaust on",NULL_KEY);
llWhisper(-14,message);
CODE

then I have the now reworked script at the bottom of Eltee's particle script:
CODE

default {

state_entry()
{
llListen(-14,"","","");
}

on_rez(integer parameter)
{
llListen(-14,"","","");
}

listen(integer channel,string name,key id, string message)
{

if (message == "Exhaust on")
{

setParticles();
}llListen(-14,"","","");
}

on_rez(integer parameter)
{
llListen(-14,"","","");
}

listen(integer channel,string name,key id, string message)
{

if (message == "Exhaust off")
{
llParticleSystem([]);
}
}
}
CODE


This actually worked to turn off the particle script but it will not turn on. I know this is a hack job but I am slowly learning. It seems to me this script should work but I know I am obviously missing something here.

Is this the issue? setParticles(); as in nothing in the brackets? Do I need to put something in those brackets to tell the setparticles to do something?
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
02-01-2008 18:45
setParticles() seems to be a user defined function that has to be somewhere else in your script, otherwise it won't to anything.

The actual command to turn on the particles is llParticleSystem([... definition of particle-system here ...]).
Another call to llParticleSystem([]) - with really nothing in between the square brackets turns the particle system off (which is correct in your script)

So - unless there isn't a function _somewhere_ in your script that's calles «setParticles()», or if this function is there, but it's empty, your script won't do anything...

Having a closer look, though, I see that you have to listen-events in your script, which won't work...

try this:

CODE


default {

state_entry() {
llListen(-14,"","","");
}

on_rez(integer parameter){
// You don't need this, because you're setting
// the listen-command in the state_entry
//llListen(-14,"","","");

// use this instead:

llResetScript(); // Resets the script and thus executes the llListen-command
}

listen(integer channel,string name,key id, string message) {

if (message == "Exhaust off") {
llParticleSystem([]);
}

if (message == "Exhaust on") {
setParticles();
}
}
}



[edit]

another thing:

if(message == "Exhaust on";)
{
llMessageLinked(LINK_SET,0,"Exhaust on",NULL_KEY);
llWhisper(-14,message);
}

the llMessageLinked doesn't make that much sense, unless you're in a linked prim set (which I can't tell right now). To me it seems that your 2nd script gets the command through the llWhisper-command on the second line. What's the llMessageLinked-command standing for?
ahkenatan Grommet
The lovable old Primosaur
Join date: 11 Jan 2005
Posts: 193
02-01-2008 18:56
Thanks for the reply Haruki. I do have that <«setParticles()> but the brackets are empty. I've been on the wiki but can't seem to find any guidance on what should go in there.

The script you had listed looks very efficient. Makes it more clear. Thank you I'm learning alot from it.

UPDATE: After examining the menu script I discovered my h key was apparently not working right so the exhaust commands read: exaust. :(

Sooo after fixing that little screw up the whole thing works like a dream. Thanks a million Void and Haruki, especially Haruki for clarifying this so much.
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
02-01-2008 19:00
I'm guessing setParticles() is a function defined in Eltee's particle script (with which I'm not familiar), which in turn gets around to calling llParticleSystem() with a workable ruleset for making exhaust, in this case.