Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

hud with money? using string and messages

Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
05-10-2008 08:55
im having trouble with this i havent used strings in a long time and this is my idea

you have a box it says your name + how much money to give and your hud is listening for that

ex. -20 Mrc Homewood 50

hud updates and says you have $50

here is my code so far not sure what to do

CODE

integer M;
stats()
{
llSetText("$" + (string)(M),<1,1,1>,1);
}
default
{
state_entry()
{
M = 0;
llListen(-20,"","","");
llSetTimerEvent(.1);
}
listen(integer channel, string name, key id, string message)
{
llWhisper(0,message);
M = (integer)message + M;
stats();
}
timer()
{
stats();
}

}
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
05-11-2008 06:29
anyone?

ive been playing with llList2CSV but wosent haveing much luck
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
05-11-2008 06:50
Well, including the name at the start means that (integer)message is always 0. You need to parse the message string first. Try something along the lines of:

CODE


list bits = llParseString2List(message, [" "], []);
if (llKey2Name(llGetOwner()) == llList2String(bits, 0) + " " + llList2String(bits, 1)) {
M += (integer)llList2String(bits, 2);
stats();
}



I would also question the value of having the money text update on a 0.1s timer! It only needs updating when M changes.
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!

http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal

http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
05-11-2008 13:03
jsut one of those dumb little things i do :P

edit:

works thanks