Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Listen Messages to Integer

Sollie Villota
Registered User
Join date: 22 Jun 2007
Posts: 46
08-17-2007 14:42
Hello.

I'm trying to figure out how to take a message from a listening channel and turn it into an integer, the way I'm trying to do it isn't working out. Here's what I have.

CODE

integer healthlisten;

default
{
state_entry()
{
llSetTimerEvent(1);

llListen(4859,"",llGetOwner(),"");
llSetAlpha(0.0, ALL_SIDES);
}
listen(integer channel, string name, key id, string message)
{
(string)healthlisten == message;
}
timer()
{
llSetText((string)healthlisten, <1,0,0>, 1.0);
}
}


The only thing that shows up is a 0 and not what SHOULD be showing up, which is other object's "health".
RJ Source
Green Sky Labs
Join date: 10 Jan 2007
Posts: 272
08-17-2007 14:47
Try:

listen(integer channel, string name, key id, string message)
{
healthlisten = (integer)message;
}
Sollie Villota
Registered User
Join date: 22 Jun 2007
Posts: 46
08-17-2007 15:15
No go. Stiill shows up as 0. Hm....
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
08-17-2007 15:30
Do a llOwnerSay one the message that listen is receiving..

/me bets that it's not something that can be converted to an int.
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
08-17-2007 15:31
I'd suggest using an llOwnerSay(message); prior to the healthlisten = (integer)message; to confirm that the value of message is as you expect.

Casting a string that contains no numbers to an integer will return 0.
Sollie Villota
Registered User
Join date: 22 Jun 2007
Posts: 46
08-17-2007 15:38
Thanks for the help, it was a dumb mistake. I forgot the llListen(4859,"",llGetOwner(),"";);. needed it to be NULL_KEY for now x.x