Jump to content
Sign in to follow this  
Rhemah

llOwnerSay Help pls!

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

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

Recommended Posts

i want to create like five different OwnerSay, can someone give me an idea?

integer sayit = TRUE;

default
{
    touch_start(integer total_number)
    {
        if(llDetectedKey(0) == llGetOwner())
        {
            if(sayit)
            {
                llOwnerSay("First!");
                sayit = FALSE;
            }
            else if(!sayit)
            {
                llOwnerSay("Second!");
            }
        }
    }
}
// i want to like create more llOwnerSay("Third!"); to Fifth if possible

 

Share this post


Link to post
Share on other sites


Rhemah wrote:

i want to create
like
five different OwnerSay, can someone give me an idea?
integer sayit = TRUE;default{    touch_start(integer total_number)    {        if(llDetectedKey(0) == llGetOwner())        {            if(sayit)            {                llOwnerSay("First!");                sayit = FALSE;            }            else if(!sayit)            {                llOwnerSay("Second!");            }        }    }}

// i want to
like
create more llOwnerSay("Third!"); to Fifth if possible

 


Well, since you have declared an integer, use it as an integer instead of a boolean.  TRUE/FALSE are two states but that integer can contain lots of numbers so just use 1, 2, 3, 4, 5 and test for 1,2,3,4,5 instead of TRUE or FALSE.

 

  • Like 1

Share this post


Link to post
Share on other sites

The classic solution is an if else chain:

integer saywhat;default {    touch_start(integer num) {    	    	if (llDetectedKey(0) == llGetOwner()) {    		    		++saywhat;    		    		if (saywhat==1)    		{    			llOwnerSay("first");    		}    		else if (saywhat==2)    		{    			llOwnerSay("second");    		}    		else if (saywhat==3)    		{    			llOwnerSay("third");    		}		else    		    		{    			llOwnerSay("last");    		}    		    	}    }}

count up saywhat on every touch and run through the chain to find an answer.

Can become quite lengthy. Sometimes you can replace that by another solution like this:

integer saywhat;default {    touch_start(integer num) {    	    	if (llDetectedKey(0) == llGetOwner()) {    		    		list answers = ["first","second","third","last"];    		integer length = llGetListLength(answers);     		    		++saywhat;    		if (saywhat > length) saywhat=length;    		    		    		llOwnerSay(llList2String(answers,saywhat-1));    		    	}    }}

Here you only add elements to the list if you need more answers. If that is useful depends on the single case. I often use list pickers instead of if else chains if that makes sense.

 

 

 

Share this post


Link to post
Share on other sites

Another way of doing the list-picker is

integer counter;
integer max;list answers = ["first","second","third","last"];default{ state_entry() { max = llGetListLength(answers); } touch_start(integer total_number) { llOwnerSay(llList2String(answers,counter%max)); ++counter; }}

Share this post


Link to post
Share on other sites
You are about to reply to a thread that has been inactive for 1827 days.

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...