- Forums
- :
- Creation Forum
- :
- LSL Scripting
- :
- Re: Script to give chat command on HUD button
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Script to give chat command on HUD button
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-06-2012 06:10 PM
Sorry for the confusing title hahaha... but that´s what I was looking for.
I have a helmet taht turns on a laser particle when I use the chat comand "/1l1" (it´s a lowercase L).
Ihave a hud that works for other functions, but I wanted to add that one. My question is... can I put a script in the HUD button that simply "recreate" the chat command"?
If not I´ll post the HUD script I have.
Thanks a lot as usual.
Re: Script to give chat command on HUD button
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Reply to Pushit - view message
02-06-2012 07:08 PM
Adding the few lines required in the HUD script to issue the chat command is easy, whether it is for a click on a prim or on a part of texture.
The big question is: Will the helmet obey to the HUD?
What you must check is if the helmet listens to owner only or to his/her objects too. The latter is what you need.
First, you need a (wide open) listener on channel 1:
llListen(1, "", NULL_KEY, "");
Then you check who or what is talking to you:
listen(integer channel, string name, key id, string msg)
{
if (llGetOwnerKey(id) == llGetOwner())
{
// Activate laser...
//
// It works for both yourself and your objects
// because for LSL you also own yourself.
}
}However, I strongly suggest to change that channel 1. It is a quite busy channel. A very negative channel is what is recommended for object to object communications. It can also be a very large positive number if you want to still be able to give commands directly through chat.
Re: Script to give chat command on HUD button
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Reply to Pushit - view message
02-06-2012 07:24 PM
Thanks a lot Kaluura for your time and help. I tried but still didn´t work, I´m obviously doing something wrong in the HUD script. Let me show you...
integer ci_SYSTEM_CHANNEL = -1409001000; // Base Communications Channel for NI01 Project.
key gkOwnerKey;
string gsOwnerName;
integer giSystemChannel;
//integer giSystemListen;
unStartUp()
{
gkOwnerKey = llGetOwner();
gsOwnerName = llKey2Name(gkOwnerKey);
//giSystemListen = llListen(ci_SYSTEM_CHANNEL,"",NULL_KEY,"");
}
default
{
on_rez(integer eiStart) { unStartUp(); }
state_entry() { unStartUp(); }
touch_start(integer eiNum)
{
if( llDetectedKey(0) == gkOwnerKey )
{
integer viLinkNum = llDetectedLinkNumber(0);
if( llGetLinkName(viLinkNum) == "HUDBUTTON" )
{ llRegionSayTo( gkOwnerKey,ci_SYSTEM_CHANNEL,"NI01|MWS|NULL|USERIN PUT|"+(string)llGetLinkPrimitiveParams
(viLinkNum,(list)28) ); }
}
}
}
And this is the helmet script
particle()
{
I didn´t paste the code to save space in the post
}
default
{
state_entry()
{
particle();//start the particle effect
llListen(0,"","","");
llListen(1, "", NULL_KEY, "");
}
changed(integer change)
{
if(change & CHANGED_OWNER)
llResetScript();
}
listen(integer channel,string name,key id,string msg)
{
if (llGetOwnerKey(id) == llGetOwner())
{
string msg = llToLower(msg);
if(msg == "l1")
{
particle();//turns the particle on
}
else if(msg == "l0")
{
llParticleSystem([]);//turns the particle off
}
}
}
}
THanks again
Re: Script to give chat command on HUD button
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Reply to Pushit - view message
02-07-2012 02:20 AM - last edited on 02-07-2012 11:50 AM
First thing:
llListen(0,"","","");
Take a scalpel, cut around this line, then use a big hammer and hit it until it pops out from the back of your screen. Such a line floods your script with all the chat from all the avatars within range. I really don't think you need it.
Next, you use a very negative channel, that's good... Except that the helmet does not listen to this channel. Here are 2 new skeleton scripts:
// HUD Script
//
integer CHANNEL = -1409001000;
key OWNER_KEY;
integer LASER_BUTTON;
integer OTHER_BUTTON_1; // Just as example.
integer OTHER_BUTTON_2; // Idem.
integer LaserStatus;
uuInit()
{
OWNER_KEY = llGetOwner();
LaserStatus = TRUE;
//
integer i = llGetNumberOfPrims();
for (; i > 0; --i)
{
string name = llToLower(llGetLinkName(i));
if (name == "laser") { LASER_BUTTON = i; }
else if (name == "other1") { OTHER_BUTTON_1 = i; } // Just as example.
else if (name == "other2") { OTHER_BUTTON_2 = i; } // Idem.
}
}
default
{
on_rez(integer param)
{
uuInit();
}
state_entry()
{
uuInit();
}
touch_end(integer num)
{
if (llDetectedKey(0) == OWNER_KEY) // Paranoid safety measure
{
integer link = llDetectedLinkNumber(0);
if (link == LASER_BUTTON)
{
LaserStatus = !LaserStatus; // Invert ON/OFF
llRegionSayTo(OWNER_KEY, CHANNEL, "l" + (string)LaserStatus);
llSetLinkColor(link, <!LaserStatus, LaserStatus, 0>, ALL_SIDES); // Eventually...
}
else if (link == OTHER_BUTTON_1)
{
// Do something else...
}
else if (link == OTHER_BUTTON_2)
{
// And something different...
}
}
}
}
// Helmet script
//
integer CHANNEL = -1409001000;
uuLaser(integer flag)
{
if (flag) // Switch on
{
llParticleSystem([
// >>>>>
// Big list of params goes here...
// <<<<<
]);
}
else // Switch off
{
llParticleSystem([]);
}
}
uuInit()
{
llListen(CHANNEL, "", NULL_KEY, "");
uuLaser(TRUE);
}
default
{
on_rez(integer param)
{
uuInit();
}
state_entry()
{
uuInit();
}
listen(integer channel, string name, key id, string msg)
{
if (llGetOwnerKey(id) != llGetOwner()) { return; }
//
if (msg == "l0")
{
uuLaser(FALSE);
}
else if (msg == "l1")
{
uuLaser(TRUE);
}
}
}Use them wisely! ;P
Note: The HUD script expects the button commanding the laser to be labelled "laser" (upper or lower case, or both).
Re: Script to give chat command on HUD button
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Reply to Pushit - view message
02-07-2012 07:16 AM
Thanks so much kallura for taking this time.
The helmet script saves perfectly... I have a problem with the HUD script in this line
string name = llTolower(llGetLinkName(i));
it says "name not defined within scope"
I tried some small changes but had no luck.
Thank you again.
Re: Script to give chat command on HUD button
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Reply to Pushit - view message
02-07-2012 07:40 AM
It should be: string name = llToLower(llGetLinkName(i));
Re: Script to give chat command on HUD button
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Reply to Pushit - view message
02-07-2012 08:23 AM - last edited on 02-07-2012 11:52 AM
Exactly... llToLower()
Functions of which the name begins with "ll" are "system functions" which can be looked up in the wiki.
You did not do your homework... Tsk, tsk tsk!
![]()
(Script fixed.)
Second edit: And yes...
key OWNER_KEY;
(Grumble, grumble...)
Re: Script to give chat command on HUD button
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Reply to Pushit - view message
02-07-2012 08:28 AM - last edited on 02-07-2012 08:32 AM
Thanks Nuclear... you are right.
Unfortunately now the problem is
OWNER_KEY = llGetOwner();
it asys type mismatch ![]()
I´m sorry to be a pain... I can not script as you can see.
Thanks!
EDIT: hahaha sorry Keluura I should have looked up that one in google... shame on me ![]()
Re: Script to give chat command on HUD button
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Reply to Pushit - view message
02-07-2012 09:35 AM
The line near the top of the HUD script that reads
integer OWNER_KEY;
should be
key OWNER_KEY;
Re: Script to give chat command on HUD button
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Reply to Pushit - view message
02-07-2012 10:43 AM
Oh thank you very much all of you!!!! Kaluuga for the amazing scripts and Nuclear and Fluffy for the pricelss help.
It works like a charm!!!!

