Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

communications ??

Bizcut Vanbrugh
Registered User
Join date: 23 Jul 2006
Posts: 99
10-06-2006 18:33
ok i am trying to develop a hud for issueing and recieving combat comands. i have read up on the wisper say and shot commands. i have seen the llMessageLinked command and a IM command. what is going to be the best method for sending commands to another hud and having that hud llSetText to display it?? thanks for any help
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
10-06-2006 18:50
well instant messages cant be received by objects and it has a 2 second delay..

linked messages only work between prims that are linked ...

so your only inworld option is llSay, llShout, or llWhisper ...they are the same except distance whisper is short ranged and shout is long ranged
Zeera Xi
Real Join Date: Mid '05
Join date: 21 Sep 2006
Posts: 54
10-07-2006 04:53
Use the WIKI
Bizcut Vanbrugh
Registered User
Join date: 23 Jul 2006
Posts: 99
10-07-2006 04:56
thank you Osgeld Barmy i appericate you help. it is nice to know that some people actualy try to help people better understand what they may (obviously) be having troubles with and not take the cowards way out. Like i said it is appericated. thanks. i did go back and look at it indepth some more.
Ishtara Rothschild
Do not expose to sunlight
Join date: 21 Apr 2006
Posts: 569
10-07-2006 10:38
Osgeld is right, having one prim or linkset whispering / llSaying / shouting on an invisible channel and another one listening is the usual method. If your HUD communicates with weapons or other objects worn by the HUD user, llWhisper is more than sufficient (has a range of 10 meters). To have 2 HUDs communicating with each other, I'd use llSay. Shouting is only needed if the commands have to be heard throughout the whole sim.

Basically it would look like this:
CODE
startup()
{
llListen(-5758,"",NULL_KEY,"message text"); //listens for a command on chat channel -5758;
// every chat channel but channel 0 is invisible in the public chat.
llListen(-5758,"",NULL_KEY,"another message text");
// if you only use a small number of commands, it will be more performant to listen to
// specific commands. But you can also listen to everything on the specified channel
// using only llListen(-5758,"",NULL_KEY,"");
}

default
{
state_entry()
{
startup(); // triggers the startup event when the script starts running
}
on_rez(integer nevermind)
{
startup(); // triggers the startup event again when the HUD is rezzed or attached
}
touch_start(integer total_number) // HUD button clicked
{
llSay(-5758, "message text"); // uses channel -5758 to send a message to another HUD
}
listen(integer chan, string name, key id, string mes)
{
if (mes=="message text")
{
// do something
}
else if (mes=="another message text")
{
// do something else
}
}
}


The simple script above will work if your HUD object consists of one scripted prim only. A script won't listen to its own llSay or llWhisper, so it won't trigger its own events. But with a linkset consisting of several buttons you'll run into problems. There are several solutions, like excluding the ID of the linked prims or sending the owner ID together with the message. The easiest solution would be though to have only one prim in the linkset llSaying / whispering, with the button prims sending linkset messages to the prim with the main script. Could look like:

CODE
// script for the child prims used as HUD buttons
default
{
touch_start(integer total_number)
{
llMessageLinked(LINK_SET,1,"button1",llDetectedKey(0));
// sends the message "button1" to all other linked prims when clicked
}
}

CODE
// script for the root prim
startup()
{
llListen(-5758,"",NULL_KEY,"message text");
llListen(-5758,"",NULL_KEY,"another message text");
}

default
{
state_entry()
{
startup();
}
on_rez(integer nevermind)
{
startup();
}
link_message(integer link, integer num, string mes, key id)
{
// listens to linkset messages sent by the child prims
if (mes=="button1") llSay(-5758,"message text");
else if (mes=="button2") llSay(-5758,"another message text");
}
listen(integer chan, string name, key id, string mes)
{
if (mes=="message text")
{
// do something
}
else if (mes=="another message text")
{
// do something else
}
}
}
Bizcut Vanbrugh
Registered User
Join date: 23 Jul 2006
Posts: 99
10-08-2006 03:35
thanks that code helps alot. i am planning on having some commands issued from my hud. the squad members will be reciving them. when they recieve them it will disp[laya llSetText message in there HUD. i appericate the help loads. you have got me headed in the correct direction
Foolish Frost
Grand Technomancer
Join date: 7 Mar 2005
Posts: 1,433
10-08-2006 05:47
From: Zeera Xi


<raised eyebrow>

How about you use basic manners? That was rude, unhelpful, and make you look like a twittering magpie. Trifecta of uselessness.

As to communication:

I have found that the llchat functions listed above are the most useful, overall, but keep this in mind: Sims have limited chat resources. When chat traffic (the number of chat entries 'said' during a timeperiod) becomes too dense in a SIM area (the whole sim), then chat is lost without error or warning.

Worse, if you have a system to have it try again if the chat did not get a response, then the system will make things worse by repeatidly trying to say the same thing over and over, flooding the chat channels but never getting through.

What this means is you can use chat, you just have to keep it within reasonable limits, and understand that the more people using it, the heavier the chat density gets.

And look out for communication feedback loops. That's where you send a message from a->b and b sends a reply, and then a sends a reply, and then b... You get the idea. They can make for a quick crash.

That's it for me, the other covered it nicly.