Jump to content

Change script with touch start to trigger on chat command


Dorian Meredith
 Share

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

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

Recommended Posts

I'm looking to change this part of a script so that it works on chat command rather than by touch.  When it comes to scripting I am completely useless.  Any suggestions on where to start?

default
{
    state_entry()
    {
        // Get the Prim Bulb Face from the numerical value in Edit -> General -> Description
        // DEFAULTS to ZERO (0) if cannot be obtained.
        list myParams = llGetPrimitiveParams([PRIM_DESC]);
        intBulbFace = llList2Integer(myParams, 0);

        updateLight();  
    }

    touch_start(integer total_number)
    {
        lightOn = !lightOn;
        
        updateLight();
    }
}

 

Link to comment
Share on other sites

2 hours ago, Dorian Meredith said:

I'm looking to change this part of a script so that it works on chat command rather than by touch.  When it comes to scripting I am completely useless.  Any suggestions on where to start?

key owner;

default
{
    state_entry()
    {
        // Get the Prim Bulb Face from the numerical value in Edit -> General -> Description

        owner = llGetOwner();
        llListen(PUBLIC_CHANNEL, "", owner, "");// channel PUBLIC for testing only. PUBLIC_CHANNEL = 0


        // DEFAULTS to ZERO (0) if cannot be obtained.
        list myParams = llGetPrimitiveParams([PRIM_DESC]);
        intBulbFace = llList2Integer(myParams, 0);

        updateLight();// have no idea what this is. It would be a user defined function. But no user defined function was defined.
    }
    listen( integer channel, string name, key id, string message )
    {
        if( message == "lightOn" )
        {
            //do stuff
        }
        if( message == "lightOff" )
        {
            //do this stuff
        }
    }
}

To give you an idea.

Edited by steph Arnott
Link to comment
Share on other sites

4 hours ago, Dorian Meredith said:

Etc...

Using your variables and functions

integer listenChannel==0;   //Here for ease of use for you. Change to whatever channel you want to say the message on. 0 is local chat
integer intBulbFace;
integer lightOn=FALSE;
updateLight(){
    //Whatever
}
default{
    state_entry(){
        llListen(0,"",llGetOwner(),"");
        intBulbFace = llList2Integer(llGetPrimitiveParams([PRIM_DESC]), 0);
        updateLight();  
    }
    listen(integer channel, string name, key id, string message){
        if(message=="light"){
            if(lightOn){
                //Turn off
                updateLight();
            }else{
                //Turn on
                updateLight();
            }
            lightOn=!lightOn;
        }
    }
}

 

Link to comment
Share on other sites

I think, though I can't be sure without seeing what updateLight() actually says -- the listen event simply needs to be

	listen(integer channel, string name, key id, string message)
	{
		if("light" == llToLower(message)){
			lightOn = !lightOn;//switch the value of lightOn between FALSE and TRUE
			updateLight();
		}
	}

 

  • Like 1
Link to comment
Share on other sites

13 minutes ago, Innula Zenovka said:

I think, though I can't be sure without seeing what updateLight() actually says -- the listen event simply needs to be


	listen(integer channel, string name, key id, string message)
	{
		if("light" == llToLower(message)){
			lightOn = !lightOn;//switch the value of lightOn between FALSE and TRUE
			updateLight();
		}
	}

 

Which assumes an On/Off. Which is why i deliberately used  comparissons. Though the llToLower( message ) make good sense.

Edited by steph Arnott
  • Like 2
Link to comment
Share on other sites

18 hours ago, steph Arnott said:

Which assumes an On/Off. Which is why i deliberately used  comparissons.

Yes, I agree.  I took it from the OP's original example, where it looks to me as if the mysterious updateLight() function uses the value of lightOn, which switches between TRUE and FALSE, but we need to see the function to be sure.

Edited by Innula Zenovka
  • Like 2
Link to comment
Share on other sites

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