Thanks for the swift reply. It's got me part-way there.
At the moment, I've got this (I used list functions because I understand them a bit better than I do string functions, but I think the end result is the same):
list remarks;
string fullname;
string firstname;
string myname;
string touchername;
string getFirstName(string fullName)
{
return llList2String(llParseString2List(fullName,[" "],[]),0);
}
integer position = 0;
string notecard;
key query;
default
{
state_entry()
{
fullname = llKey2Name(llGetOwner());
firstname = getFirstName(fullname);
myname = llGetObjectName();
notecard = llGetInventoryName(INVENTORY_NOTECARD, 0);
if(llGetInventoryType(notecard) == INVENTORY_NOTECARD)
{
llOwnerSay("Reading Configuration Notecard.");
query = llGetNotecardLine(notecard, position);
}
else
{
llOwnerSay( "Configuration notecard is not present in the object's inventory.");
}
}
dataserver(key request, string data)
{
list scratch;
if(query == request) {
if(data == EOF) {
llOwnerSay("Ready");
}
else {
scratch =[];
scratch = llParseString2List (data,[" "],[""]);
integer index = llListFindList (scratch, ["%firstname%"]);
if(index != -1){
scratch = llListReplaceList(scratch, [firstname],index, index);
}
index = llListFindList (scratch, ["%myname%"]);
if(index != -1){
scratch = llListReplaceList(scratch, [myname],index, index);
}
index = llListFindList (scratch, ["%touchername%"]);
if(index != -1){
scratch = llListReplaceList(scratch, [touchername],index, index);
}
remarks += llDumpList2String(scratch, " ");
position ++;
query = llGetNotecardLine(notecard, position);
}
}
}
touch_start(integer total_number)
{
touchername = llDetectedName(0);
llSay(0, llList2String(remarks,0));
}
changed(integer change)
{
if (change & CHANGED_INVENTORY){
llResetScript();
}
}
}
With a one-line config card reading
From: someone
%touchername% has just touched %firstname% 's %myname%
this gives me " box: has just touched Innula 's box" when I touch it.
My problem is that firstname and myname have values by the time we get to the dataserver event, but touchername doesn't. Is there any way round this other than not replacing touchername in the dataserver but in the touch_start event instead?
There's also a more minor problem that I have to put in a space between the 's and firstname; if my card reads, "has just touched %firstname%'s box", but I think I can figure that out.
My question about setting what a hug/kiss attachment was a general one; I'm trying to write one at the moment and wanted to give people the option of changing what the device says without having to edit the script or -- if I can avoid it -- their having to edit a notecard either.
It's really the same problem -- how do I reference variables other than by editing the script itself?