Jump to content

Script to give chat command on HUD button


Pushit1488312089
 Share

You are about to reply to a thread that has been inactive for 4245 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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|USERINPUT|"+(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

Link to comment
Share on other sites

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).

  • Like 1
Link to comment
Share on other sites

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! :matte-motes-angry: :matte-motes-wink:

(Script fixed.)

Second edit: And yes...

key OWNER_KEY;

(Grumble, grumble...)

  • Like 1
Link to comment
Share on other sites

Thanks Nuclear... you are right.

Unfortunately now the problem is

OWNER_KEY = llGetOwner();

 

it asys type mismatch :matte-motes-confused:

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 :matte-motes-bashful-cute:

Link to comment
Share on other sites

  • 6 months later...
You are about to reply to a thread that has been inactive for 4245 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...