Jump to content

HUD for Sailboat - Adding a second listen channel for hud control?


woogalie
 Share

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

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

Recommended Posts

Hello again, next challenge! :D I am now going to attempt to make HUD control for my sailboat. I have just one single cube on my HUD for now, and it contains this script:

default
{
    //When someone starts touching the prim
    touch_start(integer num_detected)
    {
        llSay(-99, "raise");
    }
}

 

I believe the next challenge is adding a listen to the main boat script so that it listens on channel 0 but ALSO on -99. Below I will provide the 2 locations I found when searching "listen".

//Section 1 with listen

//GENERAL BOAT STARTUP - reset stuff - this resets the script to defaults... you may call this function as needed...

startup() {
    owner=llGetOwner();
    llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Z | STATUS_ROTATE_Y,TRUE);
    llSetStatus(STATUS_PHYSICS,FALSE);
    llSetStatus(STATUS_PHANTOM,FALSE);
    llSetStatus(STATUS_BLOCK_GRAB,TRUE);
    llSetTimerEvent(0);
    setInitialPosition();
    setVehicleParams();
    setSitTarget();
    getLinkNums();                               
    llMessageLinked(SAIL,1000,"",NULL_KEY);     //reset MAINSAIL
    llMessageLinked(JIB,1000,"",NULL_KEY);      //reset JIB
    llMessageLinked(BOOM,1000,"",NULL_KEY);      //reset BOOM
    llMessageLinked(BOOM2,1000,"",NULL_KEY);      //reset BOOM2
    llMessageLinked(JIBBOOM,1000,"",NULL_KEY);      //reset JIBBOOM
    llMessageLinked(FURLED,1001,"",NULL_KEY);      //reset Furl
    llMessageLinked(CREWMAN,1001,"",NULL_KEY); // show crewman poseball
    llMessageLinked(POLE,1000,"",NULL_KEY); // hide & reset pole
    llMessageLinked(SPINNAKER,1000,"",NULL_KEY); //reset SPINNAKER
    setCamera(); //apply Camera default setting
    currSpeed=0;
    llListen(0,"",owner,""); //listen to boat owner only...
    llOwnerSay("Ready.");
    llMessageLinked(LINK_ALL_CHILDREN , 0, "stop", NULL_KEY);
}

// ------------------------------------- END GLOBAL BOAT EQUATIONS AND FUNCTIONS---

 

//Section 2 with a listen

 ////////////////////////////////////////////////////////////////////
    // MAIN BOAT LISTENER /////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////
    
    // YOU BETTER NEVER EDIT THE FOLLWING LINES UNLESS YOU KNOW WHAT TO DO :)
    
    listen(integer channel, string name, key id, string msg) {
        if (channel==0) {
            if (owner==id & llAvatarOnSitTarget()==owner) {
                if (llGetAgentInfo(owner) & AGENT_ON_OBJECT) {
                    if (llGetSubString(msg,0,4)=="sheet") {
                        incr=(integer)llDeleteSubString(msg,0,4);
                        sheetAngle+=incr;
                        if (sheetAngle>90) sheetAngle=90;
                    }
                    //MESSAGE raise - hey we DO want to sail huh?
                    else if (msg=="raise") {
                        llMessageLinked(LINK_ALL_CHILDREN , 0, "start", NULL_KEY);
                        sailing=TRUE;
                        if (!permSet) llRequestPermissions(owner,PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION);
                        permSet=TRUE;
                        llSetStatus(STATUS_PHYSICS,TRUE);
                        raiseSail();
                        llSetTimerEvent(timerFreq);
                        wTimer="normal";
                    }
                    
                     else if (msg=="debug") wDebug=1;

                    else if (msg=="t") {
                        wTack=1;                    
                        llSetTimerEvent(timerFreq/10);
                        wTimer="rapide";
                        wIndTimer=0;
                        }
                    
                    // SPINNAKER HOIST/DROP
                    else if (msg=="spin" && SPIN_UP) DropSpin();
                    else if (msg=="spin" && !SPIN_UP) HoistSpin();

                    //SPINNAKER TRIM
                    else if (msg=="spin+") TrimSpinPlus();
                    else if (msg=="spin-") TrimSpinMinus();

                    //GYBE POLE
                    else if (msg=="gybe") {
                        if (SPIN_UP==TRUE) {
                            llMessageLinked(SPINNAKER,1004,"",NULL_KEY); //hoist spinnaker
                            if (-sailingAngle > 0) llMessageLinked(POLE,1003,"",NULL_KEY);
                            if (-sailingAngle < 0) llMessageLinked(POLE,1004,"",NULL_KEY);
                            CurSpin=0;
                        }
                    }
                    
                    //MESSAGE lower - okay now we want physics ON but no sailing...
                    else if (msg=="lower") lowerSail();
                    else if (msg=="moor") {
                        llMessageLinked(LINK_ALL_CHILDREN , 0, "stop", NULL_KEY);
                        moor();
                        llSetTimerEvent(0);
                        if (SAIL_UP) lowerSail();
                        llResetScript();
                    }
                    
                    //BOAT ID Setter
                    else if (llGetSubString(msg,0,1)=="id") {
                        if (llGetSubString(msg,3,-1)!="off") {
                            idStr=llGetSubString(msg,3,-1);
                            string tmp=boatName+" #"+idStr;
                            llSetObjectName(tmp);
                            llWhisper(0,"New Boat ID :"+tmp);
                        }
                    }
                    
                    //START bbk_helmsman ANIMATION
                    else if (llGetSubString(msg,0,3)=="anim") {
                        if (llGetSubString(msg,5,-1)=="off") {
                        }
                        else if (llGetSubString(msg,5,-1)=="on") {
                            if (permSet) llStartAnimation("bbk_helmsman"); // change thise pose/animation name if needed...
                        }
                    } 

                }
            }

            //-------------------------------- END MAIN BOAT LISTENER ---
            

 

:D I will be working more on how to solve this in the morning. Have a great day or night if your reading this!

 

Edited by woogalie
Link to comment
Share on other sites

You can listen to up to 65 channels at once (though heaven only knows why you'd want to listen to so many!).   Simply open two listeners, one listening to the owner on 0 and one listening to anything on -99.   To ensure your boat listens only to your HUD, not anyone else's, you need to do some filtering in the listen event.   So, something like this:


default
{
	state_entry()
	{
		llListen(0,"",llGetOwner(),"");
		llListen(-99,"","","");
	}


	listen(integer channel, string name, key id, string message)
	{
		if(channel == 0 ||llGetOwnerKey(id) == llGetOwner()){
			//if it's on 0 -- in which case the simulator has already filtered out messages
			//or if the message is from an object that is owned by my owner

		}
	}
}

If your script has state changes, be aware that listeners do not survive them and that you will have to re-open them in the state_entry event of the new state.

Link to comment
Share on other sites

In my HUD, I have this script and does it look ok?

default
{
    //When someone starts touching the prim
    touch_start(integer num_detected)
    {
        llSay(-99, "raise");
    }
}

If this looks fine as my trigger to raise the sails. I then need to figure out how to add the second listener to the script. A search did not find any State_Entry on the script, only the default at the top. Trying to add 

llListen(0,"",llGetOwner(),"");
llListen(-99,"","","");

In different spots but no luck so far. Will keep at it.

Thank you!

Link to comment
Share on other sites

30 minutes ago, woogalie said:

In my HUD, I have this script and does it look ok?

This might be a little more elegant. It only sends the message when the HUD wearer is seated on the boat, and it sends the message to the object you are sitting on only.

default
{
    touch_start(integer total_number)
    {
        key kRoot = llList2Key(llGetObjectDetails(llGetOwner(), [OBJECT_ROOT]), 0);
        if (kRoot != llGetOwner())
        {
            llRegionSayTo(kRoot, -99, "raise");
        }
    }
}

For the listen, search the script for "llListen", and add llListen(-99,"","","") where the channel zero llListen is. Hint, it's in the startup function.
the listen event filters for channel 0 at the very top. to make it work on channel -99 as well, you will have to add something above the line if (channel == 0).

Something like:

if (channel == -99)
{
      // raise my sails
)
if (channel == 0) {// this line is already in the script.

 

  • Like 1
Link to comment
Share on other sites

OK! I have successfully added a second listener to the script. 

When I say raise on channel 0, it raises. When I say raise like "/-99 raise" into chat, it raises. Very good!

Now I am trying to determine where I need to adjust the scripts so that they also accept commands from my HUD, or the object owner.

THANK YOU arton Rotaru and Innula Zenovka for the replies. 

WELL THAT'S WEIRD.........

I went back to SL after submitting this and my HUD works.... wow. 

I will write a description on what I did with the help of the two above to accomplish this. 

Thanks again

Edited by woogalie
Link to comment
Share on other sites

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