Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

titler using strings?

Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
09-16-2008 17:16
i belive i may be doing this wrong, im creating a rp titler and it dosent seam to update at all cant figure out if this is the best way to do it or not, or even what i got wrong with this one

CODE

string name = "N/A";
string age = "N/A";
string weapon = "N/A";
vector color=<1,1,1>;
title()
{
llSetText(
"RP Info\n Name: "+(string)name
+
"\n Age: "+(string)age
+
"\nHidden Weapons: "+(string)weapon
, color, 1.0);
}
default
{
state_entry()
{
llListen( 5, "", llGetOwner(), "" );
llSetTimerEvent(1);
}
listen( integer channel, string name, key id, string message )
{
string command = message;
if (llGetSubString(command, 0, 4) == "name")
{
name = llGetSubString(message, 5, -1);
}
else if (llGetSubString(command, 0, 3) == "age")
{
age = llGetSubString(message,4, -1);
}
else if (llGetSubString(command, 0, 6) == "weapon")
{
weapon = llGetSubString(message, 7, -1);
}

}
timer()
{
title();
}

}
Jodie Suisei
Lost In LSL Code
Join date: 6 Oct 2006
Posts: 66
09-16-2008 18:09
I dont know much about titlers or how they operate but there is a few things i see wrong with this.

Firstly you have an insane timer speed and if you wanted it to update the title 1 second pause before it will do anything is like trying to stick your hand into hot water to fetch the money you just dropped into it , if you do it to fast you will miss picking up the money ;)

the rest of the code i recognise as substrings but your best bet is to wait for others to try to help solve what your attempting but the link below i hope will provide a little info on how you might do it :)

http://www.lslwiki.net/lslwiki/wakka.php?wakka=LibraryMultiTitler
Cappy Frantisek
Open Source is the Devil!
Join date: 27 Oct 2006
Posts: 400
check your substring indicies
09-16-2008 18:20
From: Mrc Homewood
i belive i may be doing this wrong, im creating a rp titler and it dosent seam to update at all cant figure out if this is the best way to do it or not, or even what i got wrong with this one

CODE

string name = "N/A";
string age = "N/A";
string weapon = "N/A";
vector color=<1,1,1>;
title()
{
llSetText(
"RP Info\n Name: "+(string)name
+
"\n Age: "+(string)age
+
"\nHidden Weapons: "+(string)weapon
, color, 1.0);
}
default
{
state_entry()
{
llListen( 5, "", llGetOwner(), "" );
llSetTimerEvent(1);
}
listen( integer channel, string name, key id, string message )
{
string command = message;
if (llGetSubString(command, 0, 4) == "name")
{
name = llGetSubString(message, 5, -1);
}
else if (llGetSubString(command, 0, 3) == "age")
{
age = llGetSubString(message,4, -1);
}
else if (llGetSubString(command, 0, 6) == "weapon")
{
weapon = llGetSubString(message, 7, -1);
}

}
timer()
{
title();
}

}


You may want to check you indicies for the llGetSubString functions. "name" would be 0 to 3, "age" 0 to 2 and "weapon" 0 to 5. I would also make the timer a bit longer otherwise you won't have time to say all your commands before it updates.
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
09-16-2008 18:53
Throw away the timer entirely. Just put title() inside the listen event and it will update only if there is a change.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
09-16-2008 22:10
what jesse said
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
pnc Blessed
Registered User
Join date: 27 Oct 2007
Posts: 136
09-16-2008 23:18
Yes QUite right Jesse.

Also I would consider using a List rather than a pile of string variables - then you could add in more "features" such as an inventory as you go along without having to do any code rewrites
_____________________
PNC Blessed
http://slurl.com/secondlife/Caledonia/161/26/23
Izanagi Asano
Registered User
Join date: 16 Apr 2007
Posts: 9
09-22-2008 21:55
You may also want to check if you have the running button checked in the lower left corner =P