Pages

Saturday, May 22, 2010

Remote control



Mmmmmkay so COKE asked me the other day about making a remote control for some curtains, like if you click a button then all the curtains should open or half shut or close. Well COKE I'll give you a real helpful snippet and hopefully you can figure out where to go from there. Of course if you need more help you're always welcome to ask more questions :P

Kay so here goes.

My super basic remote control script looks like this (it goes in the object that you're using to be the remote):

default
{
state_entry()
{

}

touch_start(integer total_number)
{
llRegionSay(-999, "1");
}
}
And this is the script that would go in the curtains (it would need to be the same script that controls whether they're open or closed and whatnot):

default
{
state_entry()
{
llListen(-999, "", "1bd1faad-303f-748e-bf5c-745d124e751e", "");
}
listen(integer channel, string name, key id, string message)
{
if(message == "1"){
llSay(0, "Hi everybody :)");
}
}
}
Here is an explanation of the llListen function. The parameters are like this: llListen( integer channel, string name, key id, string msg );(thanks wiki :) )
The parameters act as filters for what you want to listen for. This is great for cutting down on lag and makes sure the script doesn't have to sift through tons of unrelated chat. Channel is obviously the channel you want to listen for the message on (I used -999). Name will listen only for chat from specific av's or objects (I used "" to leave that blank). ID will filter for a specific object or avatar UUID. You'll notice that I used the UUID of a specific prim. You can get this really easily from the build menu using Emerald (see fig 1.). Msg will filter for a specific message, but since we will need to use different messages, you should leave that blank too using "".

Fig 1.
I think the "listen" event is pretty self explanatory. I have it set up so that if the message is "1", the prim will say a message. Sooooo, you can set up your remote control script to cycle through saying "open", "half_open", "close", and then set up your listener script to either open, set the curtains to half shut, or closed, based on the message.

Let me know if you have any more questions, you know where to find me :)

1 comments:

Anonymous said...

Thank you Valent1ne for paying attention..
scripts are working very well..!!
Hugs..

COKE.

Post a Comment