Friday, October 8, 2010

How Much Does Paintball Hurt

secretariat posts

Let's build a simple system that collects a message from any avatar, and sends it to the owner (ie you). In short, a sort of answering machine.
quickly make one for the aesthetic part, you are spoiled for choice: I downloaded a 'any image from Google and attach here if you want to use it.


Let's Call it a cube-eg: "Secretary" and let's size:
x = 0400 y = 0300 z = 0070 rotates 90 degrees on axis X, and go up the sides (taper) in X-20.
I made a device to be attached to the wall. Here's how I get the value window and the object:
Now I apply the texture on each side. In the one facing us, we have made the texture with the main buttons;
In the rest of the sides, we can safely add another texture (select a single face, and apply the texture)



Done .. now remains the most interesting part, the script The script should
, at the click of any avatar, collect the message through a llListen () and send all'owner (ie you) through the function llInstantMessage. Virtually receive an IM, whether you're online, whether you are offline.
Here's the code I've written in a simplified manner:

//------------------------- ----------------------------------------
integer
recorder; / / is the name of
listen
key id;
/ / the key of those who "touches" to leave the message


default {
on_rez (integer param) {

llResetScript ();}
;
state_entry () {
/ / insert a hover text in green
; llSetText
("Click to leave a message to" + llKey2Name (
llGetOwner ()), \u0026lt;0, 1, 0>, 1);}
;
touch_start (integer TOTAL_NUMBER)

{/ / now hover the text turns red and is activated listen to those who have touched the object
llSetText
("Recording in progress ...",\u0026lt; 1,0,0>, 1);
id =
llDetectedKey
( 0)
; recorder
llListen = (0, "", id ,""); ;
llSay (0, "Leave a message, you have three minutes");
llSetTimerEvent

(180);

/ / a timer that will disconnect the listen after 3 minutes (180 seconds)
}



listen (integer channel, string name, key id, string message) {

(
llGetOwner
(),
llKey2Name (id) + ": "+ Message); / / message to the owner

llSay
(0," Message sent to "+ llKey2Name (
llGetOwner ()));

llListenRemove
(recorder);
/ / if the item is done, remove the play.

llSetTimerEvent (0);

llSetText ("Click to leave a message to" + llKey2Name
(
llGetOwner ()), \u0026lt;0, 1, 0>, 1);}

timer () {
;
llSay
(0, "Timeout!");

llListenRemove (recorder);
/ / remove the play if it exceeds 180 seconds

llSetText
("Click to leave a message to" +
llKey2Name ( llGetOwner
()), \u0026lt;0, 1, 0>, 1);}

} //------------- -----------------------------------------------


Among the functions we have already seen, stands
llKey2Name (): this function does is turn a key (we get through llGetOwner
() or llDetectedKey ()) in a string with the name of the avatar corresponding .

Key2Name
does it mean that "key on behalf of
that remains is to prove it!
If you have studied some of the basics of scripting that I've entered, you could try to add a beautiful sound!
Good luck!

0 comments:

Post a Comment