Added the tree scripts, w/ comments
[ProgettoPaperellaDiGomma.git] / sensorNearbyAgents.lsl
blob829b5fc19e9c5fc4d7497d5b72b92d4ef53068a4
1 //originally written by Davide Byron
2 //this code is released under the GPLv3
3 //
4 // Produces E_AGENT_POSITION and E_NO_SENSOR event
5 // Sensor have detected an agent, the position is passed as a string
6 // Sensor have not detected anything, no params
7 //
8 // this sensor is a kind of eye for the creature. Almost everything about the external world
9 // is known via this script. Succesfully detecting food is a key feature for surviving.
11 //dedicated to Mealea, thanks for the passion you put into things and for being able to pass it on to me :)
13 //standard constants
14 integer E_AGENT_POSITION = 1;
15 integer E_NO_SENSOR = 5;
20 //vars used by the script, can be subkected to evolution one day...
21 float SensorRange = 96.0;
22 float SensorFrequency = 120.0;
27 default
30 on_rez(integer param)
32 llResetScript();
38 state_entry()
40 //Activate the sensor
41 llSensorRepeat("", "", AGENT, SensorRange, PI, SensorFrequency);
47 //nothing in sight
48 no_sensor()
50 llMessageLinked(LINK_SET, E_NO_SENSOR, "", "");
55 //something in sight, investigate further
56 sensor(integer numberDetected)
58 //pick a random object detected and broadcast it's coords within the animal body
59 integer target = (integer)llFrand( numberDetected );
60 llMessageLinked(LINK_SET, E_AGENT_POSITION, (string)llDetectedPos(target), llDetectedKey(target));