1 //originally written by Davide Byron
2 //this code is released under the GPLv3
4 // Produces E_SCRIPTED_POSITION and E_NO_SENSOR events
5 // Sensor have detected a scripted object, the position is passed as a string
6 // Sensor have not detected anything, no params
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 :)
14 integer E_SCRIPTED_POSITION
= 2;
15 integer E_NO_SENSOR
= 5;
19 //vars used by the script, can be subjected to evolution one day...
20 float SensorRange
= 96.0;
21 float SensorFrequency
= 20.0;
40 llSensorRepeat("", "", SCRIPTED
, SensorRange
, PI
, SensorFrequency
);
49 llMessageLinked(LINK_SET
, E_NO_SENSOR
, "", "");
54 //something in sight, investigate further
55 sensor(integer numberDetected
)
57 //pick a random object detected and broadcast it's coords within the animal body
58 integer target
= (integer)llFrand( numberDetected
);
59 llMessageLinked(LINK_SET
, E_SCRIPTED_POSITION
, (string)llDetectedPos(target
), llDetectedKey(target
));