Jump to content

Hud script help.


Valdaus Redenblack
 Share

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

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

Recommended Posts

Alright I've been modding for a while but only really know how to script certain things that i needed. I've been able to do doors, windows, little bity particle effects but nothing major. Today i decided to give making a hud a try for a breath weapon. I don't want it to be damaged based and I'm trying to figure out how to make a single button hud give a command to a script in an attached cone to turn on and off. I built an attached cone and I have a particle script to use but I'm unsure how to make the hud activate the script from the cone. Try as I like I couldn't seem to get it working so i came here. Can you please help me figure out what to do. I want to be able to activate a particle breath from the push of a button and I have been unable to do so.

Link to comment
Share on other sites

You will have to put the particle script into the cone and then speak to it with a script in your HUD.  Neither script i very difficult.  I assume that you already have the particle script, so all you need to do is add a listen event that turns it on or off, depending on the magic word from the HUD, and then open a channel (preferably a high negative channel) .  See llListen.   The HUD script only needs a touch_start event in which you place a llSay statement with an if test that sends the magic word to trigger the particle script.on or off. If the HUD script uses the same channel as the particle script, you're all set.

Link to comment
Share on other sites

Could you show what that looks like so i can see what I'm doing wrong cause this is the coding I have for my scripts

 

default
{
    touch_start(integer total_number)
    {
        llSay(-864563, "0");
    }
}

 

 

 

 

default
{
    state_entry()
    {
        llListen(-864563,"Poison breath hud",llGetOwner(),"Poison breath hud");
    }
    on_rez(integer message) {
              llResetScript();
    }
    listen(integer channel, string name, key id, string message) {      
        if(message == "1")
                    llSetAlpha(1.0,ALL_SIDES);
        else if(message == "0")
                llSetAlpha(0.0,ALL_SIDES);
        else if(message == "2")
            llSetAlpha(0.0,ALL_SIDES);
            else if(message == "3")
                    llSetAlpha(0.0,ALL_SIDES);
            else if(message == "4")
            llSetAlpha(0.0,ALL_SIDES);
    }    
}


Link to comment
Share on other sites

EDIT: Of course, somebody answered while I was typing... (Grumble)

As for your script: The problem is in the llListen(). You cannot use your own key as a filter. It should be the UUID of the HUD... which you cannot guess just like that. Leave it blank.

You can use your own key as filter only if the the HUD uses a blue dialog but then the name must be blank or match yours.

Previous answer, still valid:

That is quite simple. Like for any unlinked prims which want to communicate with eachother: Chat from the commanding script toward the script performing the action.

In the case of 2 attachments, just use llRegionSayTo(llGetOwner(), SomeVeryNegativeChannel, SomeMessage); in the commanding script. Despite the name, your script will not shout regionwide but just talk to its owner on a channel they cannot actually hear but which their attachments can.

Basic skeleton of an emitter:

// Commanding Script//integer SomeVeryNegativeChannel = -12345678;string SomeMessage = "Action!";default{    touch_start(integer num)    {        key owner = llGetOwner();        if (llDetectedKey(0) != owner) { return; } // Paranoid safety...        //        llRegionSayTo(owner, SomeVeryNegativeChannel, SomeMessage);    }} 

And of a receiver:

// Acting Script//integer SomeVeryNegativeChannel = -12345678;string SomeMessage = "Action!";// string NameOfTheHUD = "Commander"; // See herebelow.default{    touch_start(integer num)    {        llListen(SomeVeryNegativeChannel, "", "", "");        // To narrow the listener range, you can filter on the name of the HUD
// ***** That is what you need. *****
// llListen(SomeVeryNegativeChannel, NameOfTheHUD, "", ""); // Or on the chat string... If you expect only one string. // llListen(SomeVeryNegativeChannel, "", "", SomeMessage); // Or both. // llListen(SomeVeryNegativeChannel, NameOfTheHUD, "", SomeMessage);
// Do not bother about the UUID, it is a complicate story.
} listen(integer channel, string name, key id, string msg) { if (llGetOwnerKey(id) != llGetOwner()) { return; } // Accept only chat from your own objects. // (Alas, you cannot filter out everything which is not an attachment.) // if (msg == SomeMessage) // Necessary if the llListen() has no filter.
{ // Action! llOwnerSay("Message received:" + msg); // DEBUG } }}

 That's all.

Not tested in-world but I'm confident... :smileywink:

 

Link to comment
Share on other sites

You cannot target a specific script with some chat... Well, not easily. What you can easily do on the other hand is to talk on a specific channel and all the scripts listening on this channel will hear if they are within range.

In the case of llRegionSayTo(llGetOwner(), ...) on a negative channel, the range is as wide as the distance in between your attachments. That is zero meter since for SL servers, all our attachments are stuffed in our *ss. (Defintively not the technical term.) :smileywink:

Some other scripts may hear but there is really nothing you can do about it... except hope that their listener filters out all the unexpected messages or they might do some unexpected things.

On the other hand, the listeners can filter what they hear from the beginning and later when they actually receive a message... but that is your work to do.

Link to comment
Share on other sites

Sorry.  I just got home.  The answer to your immediate question is that the neither script needs to know the name of the other one.  All you really need to do is communicate between them on a channel that only those two scripts use. So, the basics .....

Your HUD script is like a light switch.  If it's ON when you click it, it turns OFF.  If it's OFF, turn it ON.  Whichever one it does, it has to tell the particle script.  That's it.  The whole thing.

 

integer gON; // This is the state of your switch, =TRUE if ON, =FALSE if OFF.default{    touch_start(integer num)    {        gON = !gON;    // This is the switch itself. Reverse the sense of gON.        llSay(-1234567, (string)gON);    // And here you are telling anyone listening on channel -1234567 the value of gON    }}

 On the other end, you already have the particle script.  All you need to do is tell it to listen on channel -1234567.  The bare bones have to look like this....

 

default{    state_entry()    {        llListen(-1234567,"","","");    // Listen to anybody saying anything on channel -1234567    }    listen (integer channel, string name, key id, string msg)    {        if(msg == "1")  // That is, if the message from the HUD was TRUE ( = "1")....        {            //Turn on the particles. This is where the stuff you already have goes.        }        else if (msg == "0")  // That is, if the message from the HUD was FALSE ( = "0") ....        {            llParticleSystem([]);  // Turn the particles OFF        }    }}

You can make it harder by adding safeguards and filters or making it change colors and ring bells.  You can also do sim-friendly things like turning off the listener when it's not being used.   All of those are good ideas, but the basic logic is just what I laid out.  Don't get fixated on the syntax.  You can always figure that out by looking in the LSL wiki.  The logic is what counts, and the logic here is no harder than wiring a light switch for a table lamp.  Good luck with it.

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4295 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...