Added the tree scripts, w/ comments
[ProgettoPaperellaDiGomma.git] / fractalTreeSendsItself.lsl
blob0411413033fb45cbd765ad79ac9c5e72ef59f8fc
1 //originally written by Davide Byron
2 //this code is released under the GPLv3
3 //
4 // this script senda a copy of the object it is inside (provided that
5 // the object as a copy of itself inside) to anyone who requests it.
6 // this is an experimental thing and not full developed yet. but it works.
7 // a full featured standard for this things is gonna be developed soon.
8 //
9 //dedicated to Mealea, thanks for the passion you put into things and for being able to pass it on to me :)
11 //wich version of the EcoComm standard is in use, see
12 // http://www.slecosystem.com/wiki/index.php?title=Main_Page
13 //for details
14 // this part is not documented in the EWG wiki, as it is an improvement
15 // we would like to add. This MUST be considered just a preliminary version
16 // to test out the possibility of this approach.
17 // the full standard will come soon.
18 string ECO_COMM_VERSION = "0x1";
19 string TREE_NAME;
20 string TREE_COPY_REQUEST = "FractalTreeCopyRequest";
25 //credits for this function goes to Sera Rawley and her cannon plant script, thanks.
26 //calculates the channel used to talk to this creature, pretty much unique.
27 integer getEcoCommChannel(string Version, key SourceKey)
29 return (integer)(Version + llGetSubString(SourceKey, 0, 6));
35 default
38 state_entry()
40 TREE_NAME = llGetObjectName();
41 //listen for requests
42 llListen( getEcoCommChannel( ECO_COMM_VERSION, llGetKey() ), "", "", "" );
48 on_rez(integer param)
50 llResetScript();
56 //if a fruit requests a copy of us, give it to him
57 listen( integer channel, string name, key id, string message )
59 //we only care that the message is the right one, no matter who is asking...
60 if( message == TREE_COPY_REQUEST )
62 llGiveInventory(id, TREE_NAME);