Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Group Give yes or no through Notecard config?

Happyholly Grigges
Registered User
Join date: 22 Dec 2006
Posts: 9
11-13-2009 13:23
I have been trying for a few days to figure this out and I just can't seem to get it. I am not sure what I am missing or not understanding right, but no matter what way I try I get errors or it does not work for me. :( So I am hoping someone can help me and point me in the right direction.

I have a group only giver script that I want to change around a bit. I want to change it to read conditions from a config notecard. I have been successful doing that when it comes to having it pick a greeting from the notecard, or a not in group message etc...

What I can't figure out is how do I make it so the script checks the notecard to see if I want group only on or off and if on then check for LLSameGroup and etc... Not deliver if wrong group and if off just give without checking.

Can anyone help before my brain explodes? lol

Below is the working script with group only give, with reading the notecard config for the greet and sorry message.

Any help would be greatly appreciated!
Holly


CODE

string cardName;
string GREET;
string SORRYGROUP;

integer NotecardLine;
key QueryID;
integer setnote = 00;
// 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);

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;
}
}
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 (llSameGroup(llDetectedKey(i))) // same as llDetectedGroup(i) (with llDetectedGroup, detected does not need to be in the sim)
{
llSay(0,(string)GREET);
llGiveInventory(llDetectedKey(i), llGetInventoryName(INVENTORY_OBJECT, 0));
}else
llSay(0,(string)SORRYGROUP);
}
}
}


In the config notecard...
greet=Thanks for picking me!

sorrygroup= I am so sorry, you don't seem to be in my group.
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
11-13-2009 13:33
/me pokes at the script and comes up with...

CODE

string cardName;
string GREET;
string SORRYGROUP;
integer groupOnly = TRUE; // 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 == "grouponly")
{
if (value == "0" || value == "false" || value == "no")
{
groupOnly = FALSE;
}
else
{
groupOnly = 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)))
{
llSay(0,(string)GREET);
llGiveInventory(llDetectedKey(i), llGetInventoryName(INVENTORY_OBJECT, 0));
}
else
{
llSay(0,(string)SORRYGROUP);
}
}
}

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


edit: I haven't tested this but it's probably close to what I think you want...
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Happyholly Grigges
Registered User
Join date: 22 Dec 2006
Posts: 9
11-13-2009 14:08
Thank you, thank you, thank you!! Not exactly the way I wanted, but you gave me just what I needed to know!! Enough to tweak it to how I wanted it and now learn where my errors were. I learned something new. Yay! :)

Thank you so much for helping me!
Holly