Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

HUD Commands & Listener Troubles

JR Breed
Registered User
Join date: 17 Jan 2006
Posts: 49
02-14-2007 10:54
Hello all, thank you for reviewing my thread.

I was testing my some commands that would be controled by a HUD. Im unsucsessful. Im doing it just as I see it in another set of scripts and I have no idea why its not working. All scripts are compiling and I am not getting any scripting errors after the compile or when pressing the HUD button. Here is the 3 scripts.


Here is the HUD button;
CODE

Say_Message(string command)
{
string name = llGetObjectName();
llSetObjectName(llKey2Name(llGetOwner()));
if(command == "Tester") llWhisper(3, "Test");
llSetObjectName(name);
}
default

{
touch_start(integer total_number)
{
Say_Message("Tester");
}

link_message(integer sender, integer num, string message, key id)
{
Say_Message(message);
}
}



This is the script thats listening for the HUD command and sends the message to the script I want to activate for whatever reason;
CODE

string OwnerName;
integer ListenCh = 3; //Listen channel of the HUD
string TesterCommand = "Test"; //Horn command
key Owner;
string Sound = "e874533b-a780-30bd-c0b8-313a373a3320"; // tester sound

default
{
listen(integer channel, string name, key id, string message)
{
if(llGetOwnerKey(id) != Owner) return;
message = llToLower(message);
if(message == TesterCommand) llMessageLinked(LINK_SET, 999111, Sound, NULL_KEY);
}
}


Here is the last script thats listening for the final command;
CODE

default
{
link_message(integer sender, integer num, string message, key id)
{
if(num == 999111) llPlaySound(message, 1.0);
}
}



No sound plays, no script errors. Only me pulling out my hair.
I would greatly appreciate any advice as to why this is not working for me. Thank you in advance. :)
Baron Hauptmann
Just Designs / Scripter
Join date: 29 Oct 2005
Posts: 358
02-14-2007 11:11
I'm not sure if this is the only thing, but here is one problem:

CODE

string TesterCommand = "Test"; //Horn command
.
.
.
message = llToLower(message);
if(message == TesterCommand)


your if() will ALWAYS fail because message is all lowercase and TesterCommand is capitalized.

Baron
JR Breed
Registered User
Join date: 17 Jan 2006
Posts: 49
02-14-2007 11:25
Hi baron and thank you for replying. Unfortainitly I quit dont understand what you mean.

From what I think I understand is since "message" is all lower case letters, my commands also all need to be lower case letters? I just changed "TesterCommand" to all lower case and still no change.

*Grabs my vacume and sweeps up chunks of hair*
Ravanne Sullivan
Pole Dancer Extraordinair
Join date: 10 Dec 2005
Posts: 674
02-14-2007 11:25
Your sender command is wrong. It should be something like:

llMessageLinked(integer linknum, integer num, string str, key id)

link_message(integer sender_num, integer num, string str, key id) is used on the receiving side.


http://lslwiki.org/index.php/LlMessageLinked
_____________________
Ravanne's Dance Poles and Animations

Available at my Superstore and Showroom on Insula de Somni
http://slurl.com/secondlife/Insula de Somni/94/194/27/
JR Breed
Registered User
Join date: 17 Jan 2006
Posts: 49
02-14-2007 11:58
Wow. I didnt expect it to be so complicated. I feel like I almost have the grasp of what you mean and what Im doing wrong but most likely, I have not a clue. Awww forget it, I give up. No point in getting help if I dont understand the language. :(

Thank you Ravanne for your reply.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
02-14-2007 11:58
Baron is Correct about the capitalisation, you make message all lowercase so the check ("Test";) will not match the message("test";), but thats not the only issue.

You never set up a listen in the second script so the script will never get to the listen event anyway. The second script also never sets up Owner so the ownerid check will also always fail.

The llMessageLinked Call is correct. I think Ravanne confused the fact that you have link_message handler in the first script as well as the llMessageLinked call.

Not sure why you are bothering changing the object name, it wont have any effect in this situation. This ploy is usually used when you want the prim to make you say or do something, as used in huggers and their ilk. Its also a ploy for bypassing voice activated locks.


I would suggest that if you have scripts that rely on matched data then make sure you define constants in BOTH files rather that hard code the value, its too easy to miss one when updating a script. It also removes any need to convert string cases since you know they will match.


Newgy-ied Versions of the scripts.

Script One
CODE

integer ListenCh = 3; //Listen channel of the HUD
string TesterCommand = "Test"; //Horn command
string Tester = "Tester";

Say_Message(string command)
{
if(Tester == command) llWhisper(ListenCh , TesterCommand );
}

default
{
touch_start(integer total_number)
{
Say_Message(Tester);
}
}


Script Two
CODE

integer ListenCh = 3; //Listen channel of the HUD
string TesterCommand = "Test"; //Horn command
string Sound = "e874533b-a780-30bd-c0b8-313a373a3320"; // tester sound
integer PLAYSOUND = 999111;

default
{
state_entry()
{
llListen(ListenCh,"","","");
}

listen(integer channel, string name, key id, string message)
{
if(llGetOwnerKey(id) != llGetOwner()) return;
if(TesterCommand == message)
llMessageLinked(LINK_SET, PLAYSOUND , Sound, NULL_KEY);
}
}


Script Three
CODE

integer PLAYSOUND = 999111;

default
{
link_message(integer sender, integer num, string message, key id)
{
if(PLAYSOUND == num) llPlaySound(message, 1.0);
}
}