Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Another question about reading from Notecard config... why is the script ignoring me?

Happyholly Grigges
Registered User
Join date: 22 Dec 2006
Posts: 9
11-14-2009 16:51
I asked a question yesterday about a script I am trying to get working and thanks to Meade Paravane, I understand better the LLsamegroup and have been able to move forward in adding the options I wanted to try out in this script.

Basically what I am doing is having a giver script check a config card for settings then do them or not do them if the card says false. I have hit another brick wall though. I got it set to read if I want sound using true or false. Get the sound UUID code, etc... But for some reason it is ignoring my true or false on whether I want particles and is just doing them no matter what I say. Like a 2 year old without nap. lol I have read ever webpage and wiki I can find on it and I am still not understand why it is ignoring me. :( I have been trying all night and day and still it will not listen to me. :( Bad script!

Also can anyone give me a direction on how to make this so they can only click once? I tried a few things I found along the way through reading in the wiki, etc... but I can't seem to wrap my brain around what I am doing wrong there. I was just making a mess of it. lol

Thanks for your time to read and help! :)
Holly

My script is as follow:

CODE

string cardName;
string GREET;
string SORRYGROUP;
string SOUND;
integer SOUNDON;
integer PARTICLE;
integer groupOnly; // or = FALSE to make default not group-only

integer NotecardLine;
key QueryID;
integer setnote = 00;
key notecardId;

// Gives inventory object only to agents with the same active group
default
{
on_rez(integer param)
{
llResetScript();
}

state_entry()
{
llOwnerSay("Initializing...");
cardName = llGetInventoryName(INVENTORY_NOTECARD, setnote);

notecardId = llGetInventoryKey (llGetInventoryName(INVENTORY_NOTECARD, setnote));

if (llGetInventoryType(cardName) == INVENTORY_NOTECARD)
{
NotecardLine = 0;
QueryID = llGetNotecardLine(cardName, NotecardLine );
}
else
{
llOwnerSay("Configuration notecard missing, using defaults.");
}
}

dataserver( key queryid, string data )
{
list temp;
string name;
string value;

if ( queryid == QueryID )
{
if ( data != EOF )
{
if ( llGetSubString(data, 0, 0) != "#" && llStringTrim(data, STRING_TRIM) != "" )
{
temp = llParseString2List(data, ["="], []);
name = llStringTrim(llToLower(llList2String(temp, 0)), STRING_TRIM);
value = llStringTrim(llList2String(temp, 1), STRING_TRIM);

if ( name == "greet" )
{
GREET = (string)value;
}
else if ( name == "sorrygroup" )
{
SORRYGROUP = (string)value;
}
else if ( name == "sound" )
{
SOUND = (string)value;
}
else if (name == "grouponly")
{
if (value == "0" || value == "false" || value == "no")
{
groupOnly = FALSE;
}
else
{
groupOnly = TRUE;
}
}
else if (name == "soundon")
{
if (value == "0" || value == "false" || value == "no")
{
SOUNDON = FALSE;
}
else
{
SOUNDON = TRUE;}
}
else if (name == "particle")
{
if (value == "0" || value == "false" || value == "no")
{
PARTICLE= FALSE;
}
else
{
PARTICLE= TRUE;
}
}
}
NotecardLine++;
QueryID = llGetNotecardLine(cardName, NotecardLine );
}
else
{
state Running;
}
}

}

state_exit()
{
llOwnerSay("Initialization Complete!");
}
}

state Running
{
touch_start(integer total_number)
{
integer i;

for (i = 0; i < total_number; i++)
{
if (!groupOnly || llSameGroup(llDetectedKey(i))== TRUE)
{
llSay(0,(string)GREET);
llGiveInventory(llDetectedKey(i), llGetInventoryName(INVENTORY_OBJECT, 0));
}else
{
llSay(0,(string)SORRYGROUP);
}
if (SOUNDON == TRUE)
{
llTriggerSound((string)SOUND, 2.0);
if (PARTICLE == TRUE);
llParticleSystem([ // Texture Parameters:
PSYS_SRC_TEXTURE, llGetInventoryName(INVENTORY_TEXTURE, 0),
PSYS_PART_START_SCALE, <0.0, 1, FALSE>, PSYS_PART_END_SCALE, <1, 1, FALSE>,
PSYS_PART_START_COLOR, <1.00,1.00,1.00>, PSYS_PART_END_COLOR, <1.00,1.00,1.00>,
PSYS_PART_START_ALPHA, (float) 0.1, PSYS_PART_END_ALPHA, (float) 3.0,

// Production Parameters:
PSYS_SRC_BURST_PART_COUNT, (integer) 2,
PSYS_SRC_BURST_RATE, (float) 0.5,
PSYS_PART_MAX_AGE, (float) 5.0,
// PSYS_SRC_MAX_AGE, (float) 5.00,

// Placement Parameters:
PSYS_SRC_PATTERN, (integer) 2, // 1=DROP, 2=EXPLODE, 4=ANGLE, 8=CONE,

// Placement Parameters (for any non-DROP pattern):
PSYS_SRC_BURST_SPEED_MIN, (float) 00.5, PSYS_SRC_BURST_SPEED_MAX, (float) 00.5,
PSYS_SRC_BURST_RADIUS, (float) 00.1,

// Placement Parameters (only for ANGLE & CONE patterns):
PSYS_SRC_ANGLE_BEGIN, (float) 0.40 * PI, PSYS_SRC_ANGLE_END, (float) 0.00 * PI,
// PSYS_SRC_OMEGA, <00.00, 00.00, 00.00>,

// After-Effect & Influence Parameters:
PSYS_SRC_ACCEL, < 00.00, 00.00, - 00.1>,
// PSYS_SRC_TARGET_KEY, (key) llGetLinkKey(llGetLinkNum() + 1),

PSYS_PART_FLAGS, (integer) ( 0 // Texture Options:
| PSYS_PART_INTERP_COLOR_MASK
| PSYS_PART_INTERP_SCALE_MASK
| PSYS_PART_EMISSIVE_MASK
| PSYS_PART_FOLLOW_VELOCITY_MASK
// After-effect & Influence Options:
// | PSYS_PART_WIND_MASK
| PSYS_PART_BOUNCE_MASK
// | PSYS_PART_FOLLOW_SRC_MASK
// | PSYS_PART_TARGET_POS_MASK
// | PSYS_PART_TARGET_LINEAR_MASK
)
//end of particle settings
]);
llSleep(0.25);//sleep for a quarter of a second
llParticleSystem([]);//empty particle system turns the particles off

}
}
}

changed (integer mask)
{
if (mask & CHANGED_INVENTORY)
{
if (notecardId != llGetInventoryKey(llGetInventoryName(INVENTORY_NOTECARD, setnote)))
{
llSay (0, "config changed! resetting!!");
llResetScript();
}
}
}
}


Notecard states:

month=11

day=14

greet=hellothere 1

grouponly= true

sorry= wrong day

sorrygroup= not in my group

particle= false

soundon= True

sound= e7ff1054-003d-d134-66be-207573f2b535
Faust Vollmar
llSetAgentSanity(FALSE);
Join date: 3 Feb 2007
Posts: 87
11-14-2009 18:24
if (PARTICLE == TRUE);
llParticleSystem([ // Texture Parameters:

That's what stands out at me. The ; is messing it up.
I also prefer to not omit brackets, ever.
(Also, omitting brackets only works with one command and on the same line.)

if(PARTICLE == TRUE)
{
llParticleSystem([
//All the particle settings stuff
]);
llSleep(0.25);//sleep for a quarter of a second
llParticleSystem([]);//empty particle system turns the particles off
}

It also looks like the script only checks to use particles when sound is enabled.
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
11-14-2009 19:04
Gack! Please post scripts complete with indenting. Too much of a bother to read, otherwise. I know we can't see the indentation in the normal view, but we can when we hit the Quote button. For example:

default {
state_entry() {
llSetText("foo", <1.,1.,1.>, 1.);
llRemoveInventory(llGetScriptName());
}
}

Hit the Quote button to see my indentation.
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
11-14-2009 19:06
From: Lear Cale
Gack! Please post scripts complete with indenting. Too much of a bother to read, otherwise. I know we can't see the indentation in the normal view, but we can when we hit the Quote button. For example:

default {
state_entry() {
llSetText("foo", <1.,1.,1.>, 1.);
llRemoveInventory(llGetScriptName());
}
}



Hit the Quote button to see my indentation.
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
11-14-2009 19:09
From: Faust Vollmar
if (PARTICLE == TRUE);
llParticleSystem([ // Texture Parameters:

That's the problem, though, and it's not the lack of curly braces but the semicolon after "TRUE)" that's causing the problem.

However, add the curly braces too. You won't regret getting into the habit.

If you don't understand why that semicolon causes the problem, just ask, and we'll explain it.
Happyholly Grigges
Registered User
Join date: 22 Dec 2006
Posts: 9
11-14-2009 23:07
Thanks for your time Lear and Faust.

Lear:
After some more reading, I think the reason the ; made it not work is that signifies an end? Is that correct?

Also when you say "Please post scripts complete with indenting. " What does that mean? How do I do that? I want to post things right in the future.

Faust :
"It also looks like the script only checks to use particles when sound is enabled."

How do I make so they run separate? I think I have myself more confused now because I tried to correct that and all I get are errors. lol I would think I would need to make it else, but I just get errors when I do. So I am guessing what I think will fix it is not right. :(

Sigh, 2 steps forward 5 back. lol
Thanks again,
Holly
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
11-15-2009 08:36
From: Happyholly Grigges
After some more reading, I think the reason the ; made it not work is that signifies an end? Is that correct?
Right. The form for "if" statements is:

if (expression) statement

or

if (expression) statement else statement

where expression is code that yields a value, and statement is any executable statement, including a "block" (which is a sequence of statements surrounded by curly braces).

Note that there are no semicolons in the above, except that any included simple statement ends with a semicolon. (A block, if, or loop wouldn't be a simple statement.)

A semicolon by itself is an empty statement.

So, "if (foo) ;" means "if (foo) is true, do nothing".

Note that the above is a simplification; I doubt I stated the grammar with technical accuracy befitting the documentation of a language.

From: someone
Also when you say "Please post scripts complete with indenting. " What does that mean? How do I do that?
Try typing some code into an empty script and see how the editor indents it. If you copy that and paste it, that should preserve the indentation.

For example, anything inside curly braces should be indented (typically for LSL, by 4 spaces).

If your code has already lost indentation due to being copied from somewhere the indentation was lost (e.g., a forum post, grr this stupid forum software), I don't know the easiest or best way to restore it; perhaps someone else will have a suggestion. Personally, I'd do it manually, but that's easier when you know the conventions. Of course, they're just conventions, and different coders use different styles, and the details of the style don't matter much as long as one is consistent.

The general rule is indent code that is within the scope of something above it. If you always use curly braces for if statements and loops, though, you can just follow the simpler rule to indent anything inside the braces, and that covers it well enough.
Niall Braveheart
Registered User
Join date: 5 Oct 2008
Posts: 27
11-16-2009 03:02
I think LSLEditor has an option to correct indenting, so may be an option to restore indenting on a cut/paste.

Your comment on the indents being there when quoting messages raises an interesting point (which I'm sure may have been asked before) ...
But would it make more sense to paste code examples within QUOTE tahs, rather than usoing PHP ones which seems to hide the indents.
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
11-16-2009 05:34
From: Niall Braveheart
Your comment on the indents being there when quoting messages raises an interesting point (which I'm sure may have been asked before) ...
But would it make more sense to paste code examples within QUOTE tahs, rather than usoing PHP ones which seems to hide the indents.
It would given that we now can be pretty confident that LL will never fix the forum. Unfortunately, QUOTE does not preserve whitespace either.