Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

random button box to talk

Johnathan Padar
Registered User
Join date: 27 Jul 2005
Posts: 23
04-14-2006 00:18
I was wondering how i would go about, making a box that doesn't say anything until you click on it, then it repeats each thing to say.....over and over

here is what i have, i have no clue as to what i am doing wrong with it...

default
{
state_entry()
{
llSetTimerEvent(.5);
}

touch_start(integer total_number)

{
llSleep(0.5);
llShout(0, "I like you";);

llSleep(0.5);
llShout(0, "do you like me?";);

llSleep(0.5);
llShout(0, "lets hug";);


}
}
Johnathan Padar
Registered User
Join date: 27 Jul 2005
Posts: 23
04-14-2006 02:13
never mind lol, i got it =)
Johnathan Padar
Registered User
Join date: 27 Jul 2005
Posts: 23
the closest i've gotten so far is this...
04-14-2006 02:40
default
{
state_entry()
{
llSetTimerEvent(.9);
}

touch_start(integer total_number)
{integer i;
for (i = 0 ; i < total_number ; ++i)
if (llDetectedGroup(i))

return;
llSleep(.1);
llSay(0, "i love you";);
llSleep(2);
llSay(0, "but i have gas";);
llResetScript();
return;
}
}

// it works but i have to touch the button over and over again for it to reset the script and start over
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
04-14-2006 03:37
CODE

default
{
touch_start(integer num)
{
llSetTimerEvent(0.1);
}
timer()
{
llSetTimerEvent(3.0);
llSay(0, "This is a very irritating script");
llSleep(1.5);
llSay(0, "It's not guaranteed, wrote it here, but I think it does what you want.");
}
}
Johnathan Padar
Registered User
Join date: 27 Jul 2005
Posts: 23
04-14-2006 05:33
thank you for that, but this only leads me to my next question....lol...
how the heck do i stop it?? i tried putting in touch end...didn't work right...
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
04-14-2006 06:35
You didn't ask for it to stop too!

There are two methods you could use. One is two states, touch_start() toggles the state from default to speaking and back, and only speaking says things, the other is a variable e.g. integer speaking which toggles between TRUE and FALSE and affects the timer. Depending on the rest of what you're trying to do there are swings and roundabouts for both approaches, so I've given you both.

With a flag:
CODE

integer talking = FALSE;
default
{
touch_start(integer num)
{
if(talking)
{
llSetTimerEvent(0.0);
talking=FALSE;
} else
{
llSetTimerEvent(0.1);
talking=TRUE;
}
}
timer()
{
llSetTimerEvent(3.0);
llSay(0, "This is a very irritating script");
llSleep(1.5);
llSay(0, "It's not guaranteed, wrote it here, but I think it does what you want.");
}
}


With states:
CODE

default
{
state_entry()
{
llSetTimerEvent(0.0);
}
touch_start(integer num)
{
state speaking;
}
}
state speaking
{
state_entry()
{
llSetTimerEvent(0.1);
}
touch_start(integer num)
{
state default;
}
timer()
{
llSetTimerEvent(3.0);
llSay(0, "This is a very irritating script");
llSleep(1.5);
llSay(0, "It's not guaranteed, wrote it here, but I think it does what you want.");
}
}


There are other combinations that will work with timers due to some pretty well documentated by counter-intuitive behaviour.

Can I ask, have you tried the lsl wiki at all yet? Between it and these tutorials you should find enough to help you along. If not there are organisations like TeaZers and people like me that will teach basic scripting in world for a fee.