Jump to content
Xuander

communication HUD

Recommended Posts

Hello all,

with the help of a lot people from this forum i have this script what is working almost how i want, let me explain what it is.

The script go in a object and the object is attached as hud to the avatar, when more people attach the object as hud and someone say "/66 hello" it comes on the screen of all who have the hud and it play a sound when someone sent a message, so far it is working how i want....now there is one thing i cant get to work.

I have been told that when i use llregionsay it sent the message to everyone on the region with the hud but that not work, only people who are in 20 meter range get the message and when hit CTRL the people in 100 meter get the message but i want that everyone on the region with the hud get the message.

To be clear, the message is not sent to the local chat but is sent to the hud so when you have the hud in the middle of your screen you see the message in the middle of your screen.

The other thing i hope can be fixed is that now when someone say something with "/66 hello" it sent that to all others with the hud with the name of the one who have sent it but it use the usernames and i want that it sent the displayname.

Hope someone can help me with this.

integer transmit_channel = 66;
integer listen_handle;
 
 //////////////////////////////
 
float MyFade;
string MyMessage;


say_message(string message)
{
llRegionSay(-3, message);
llPlaySound("Horn",0.5);
llSetTimerEvent(0.0);
llSetText(message, <0.004, 1.000, 0.439>, 1.0);
MyFade = 1.0;
MyMessage = message;
llSetTimerEvent(6.0);  // tick every 1 seconds.
} 
 
 //////////////////////////////
 
transmit(string message)
{
llRegionSay(transmit_channel, message);
}
 
 //////////////////////////////
 
show_help()
{
llOwnerSay("Bird Call Directions:");
llOwnerSay("/bc on: Turn on.");
llOwnerSay("/bc off : Turn off.");
llOwnerSay("/bc reset: Reset.");
}
 
 //////////////////////////////
 
default
{
state_entry()
{
llOwnerSay("Bird Call enabled");
llSetObjectName(llGetDisplayName(llGetOwner()) + " (BC)");
state on;
}
}
 
 //////////////////////////////
 
state on
{
    timer()
{
MyFade -= 0.3;   // reduce by 1/5th each time
llSetText(MyMessage, <0.004, 1.000, 0.439>, MyFade);
if (MyFade == 0.0)
llSetTimerEvent(0.0);
}

state_entry()
{
llListen(0, "", llGetOwner(), "");
listen_handle = llListen(transmit_channel, "", NULL_KEY, "");
}
 
 //////////////////////////////
 
attach(key attached)
{
if (attached != NULL_KEY)
{
llSetObjectName(llGetDisplayName(llGetOwner()) + " (BC)");
llOwnerSay("Bird Call enabled (To sent a message to your team, type in local for example /5 bandage me).  Type \"/bc help \" for directions.");
llOwnerSay("Bird Call on.");
llOwnerSay("Bird Call listening on channel " + (string) transmit_channel);
}
}
 
 //////////////////////////////
 
changed(integer change)
{
if (change & CHANGED_OWNER)
{
llResetScript();
}
}

//////////////////////////////

listen(integer channel, string name, key id, string message)
{
if (channel == 0 && id == llGetOwner() && llStringLength(message) > 4 && llGetSubString(llToLower(message), 0, 3) == "/bc ")
{
message = llDeleteSubString(message, 0, 3);
if (llGetSubString(llToLower(message), 0, llStringLength("channel ") - 1) == "channel " && llStringLength(message) > llStringLength("channel "))
{
message = llDeleteSubString(message, 0, llStringLength("channel ") - 1);
if ((integer) message != 0)
{
transmit_channel = (integer) message;
llListenRemove(listen_handle);
listen_handle = llListen(transmit_channel, "", NULL_KEY, "");
llOwnerSay("Bird Call listening on channel " + (string) transmit_channel);
}
}
 
 //////////////////////////////
 
else if (llGetSubString(llToLower(message), 0, llStringLength("off") - 1) == "off")
{
state off;
}
 
else if (llGetSubString(llToLower(message), 0, llStringLength("help") - 1) == "help")
{
show_help();
}
 
else if (llGetSubString(llToLower(message), 0, llStringLength("scan") - 1) == "scan")
{
state scan;
}
 
else if (llGetSubString(llToLower(message), 0, llStringLength("reset") - 1) == "reset")
{
llResetScript();
}
 
else
{
transmit(message);
}
}
 
 //////////////////////////////
 
else if (channel != 0)
{
if (id == llGetOwner())
{
say_message(message);
}
 
else
{
say_message(name + ": " + message);
}
}
}   
}
 
 //////////////////////////////
 
state off
{
state_entry()
{
llListen(0, "", llGetOwner(), "");
llOwnerSay("Bird Call off.");
}
 
attach(key attached)
{
if (attached != NULL_KEY)
{
llSetObjectName(llGetDisplayName(llGetOwner()) + " (BC)");
llOwnerSay("Bird Call enabled (status: OFF).  Type \"/bc help\" for directions.");
}
}
 
 //////////////////////////////
 
changed(integer change)
{
if (change & CHANGED_OWNER)
{
llResetScript();
}
}
 
 //////////////////////////////
 
listen(integer channel, string name, key id, string message)
{
if (channel == 0 && id == llGetOwner() && llStringLength(message) > 4 && llGetSubString(llToLower(message), 0, 3) == "/bc ")
{
message = llDeleteSubString(message, 0, 3);
 
if (llGetSubString(llToLower(message), 0, llStringLength("on") - 1) == "on")
{
state on;
}
 
else if (llGetSubString(llToLower(message), 0, llStringLength("help") - 1) == "help")
{
show_help();
}
 
else if (llGetSubString(llToLower(message), 0, llStringLength("scan") - 1) == "scan")
{
state scan;
}
 
else if (llGetSubString(llToLower(message), 0, llStringLength("reset") - 1) == "reset")
{
llResetScript();
}
}
}   
}
 
 //////////////////////////////
 
state scan
{
state_entry()
{
llListen(0, "", llGetOwner(), "");
listen_handle = llListen(transmit_channel, "", NULL_KEY, "");
llSetTimerEvent(5);
llOwnerSay("Channel Scanning...say \"bc stop\" to stop.");
}
 
attach(key attached)
{
if (attached != NULL_KEY)
{
llSetObjectName(llGetDisplayName(llGetOwner()) + " (BC)");
llOwnerSay("Bird Call enabled (status: SCANNING).  Type \"/bc help\" for directions.");
}
}
 
 //////////////////////////////
 
 changed(integer change)
{
if (change & CHANGED_OWNER)
{
llResetScript();
}
}
 
 //////////////////////////////
 
timer()
{
transmit_channel++;
llListenRemove(listen_handle);
listen_handle = llListen(transmit_channel, "", NULL_KEY, "");
llOwnerSay("Bird Call listening on channel " + (string) transmit_channel);
}
 
listen(integer channel, string name, key id, string message)
{
if (channel == 0 && id == llGetOwner() && llStringLength(message) > 4 && llGetSubString(llToLower(message), 0, 3) == "/bc ")
{
message = llDeleteSubString(message, 0, 3);
 
if (llGetSubString(llToLower(message), 0, llStringLength("channel ") - 1) == "channel " && llStringLength(message) > llStringLength("channel "))
{
message = llDeleteSubString(message, 0, llStringLength("channel ") - 1);
 
if ((integer) message != 0)
{
transmit_channel = (integer) message;
llListenRemove(listen_handle);
listen_handle = llListen(transmit_channel, "", NULL_KEY, "");
llOwnerSay("Bird Call listening on channel " + (string) transmit_channel);
}
}
 
 //////////////////////////////
 
else if (llGetSubString(llToLower(message), 0, llStringLength("on") - 1) == "on")
{
state on;
}
 
else if (llGetSubString(llToLower(message), 0, llStringLength("stop") - 1) == "stop")
{
state on;
}
 
else if (llGetSubString(llToLower(message), 0, llStringLength("off") - 1) == "off")
{
state off;
}
 
else if (llGetSubString(llToLower(message), 0, llStringLength("help") - 1) == "help")
{
show_help();
}
 
else if (llGetSubString(llToLower(message), 0, llStringLength("reset") - 1) == "reset")
 
{
llResetScript();
}
 
else
{
transmit(message);
}
}
 
 //////////////////////////////
 
else if (channel != 0)
{
if (id == llGetOwner())
{
say_message(message);
}
 
else
{
say_message(name + ": " + message);
}
state on;
}
}
}

 

Share this post


Link to post
Share on other sites

You don't even have message handling for the transmit_channel in the first place. You need an additional check in the listen event like you have for channel zero, except instead of "id == llGetOwner()" you need "llGetOwnerKey(id) == llGetOwner()".

The difference is that the first way checks for messages from the owner avatar only, while the second way checks for messages from the owner's objects as well. 

Also please work on your identation, this kind of code is painful for others to read and kind of difficult to follow. 

Edited by Wulfie Reanimator

Share this post


Link to post
Share on other sites

@Xuander - Wwhat you are now asking for entails you learning about: lists, attach/detach, owner, ownerkey, listen, channels and region say

the LSL wiki has lots of code examples for each of the functions and events that you need to know to create the app you want. My advice is for you to copy the wiki examples into inworld scripts, compile/run them, and study them to understand how and why they function as they do, and how what you observe relates to the LSL wiki explanatory texts. Then based on this understanding try to incorporate what you have learned into your app script

the purpose of this forum is to help you debug scripts that you write. To give you pointers on the pathways open to you on your journey to becoming a scripter. It is not the purpose of this forum to write your app for you.

The direction open to you in this now instance is the LSL wiki. Read it up, code it up. Observe what happens. Incorporate what you learn from this into your own app script. When we can see by the code you do post that you are making a reasonable effort to be a scripter in your own right then ppl on here will continue to give you pointers and guidance

if the LSL wiki is beyond your understanding at this time, there are LSL tutorials and classes held inworld at a number of venues for ppl such as yourself. Use the inworld search to find them

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...