This week we have been looking at slightly more indepth LSL scripting, mainly focused around collision and scanning.
Task 1 invloved writing a script that upon touch, stated the avatar name, then gives a suitable time related greeting, good morning/evening etc. This was achieved by creating an integer attached to the llGetGMTClock function. This is returned in seconds, counted from 00.00.
To get correct greetings, if/else statements were used. There are 3600 seconds in an hour so less than 43199 seconds is considered morning etc. Evening and Night were just extensions to this calculation.
Task 2 was composed of a script to detect the name of an Avatar or object colliding with a prim and state the speed it was travelling. It should also state the owner of the object.
Detecting the velocity was solved by a combination of llVecMag and llDetectVel. Stating the ownership of the item was linking the key to a name, then retrieving the owners name.
Task 3 was very tricky indeed. We needed to create a prim that if the owner touched, scanned a 50 radius for Avatars and list them, and if anyone else touched it, only a 25 scan was set off.
The task of identifying ownership was solved by a simple if statement. If the detected Avatar matched the owners ID then the 50 radius scan is set off, else the 25 scan is activated. The scan was set to detect agents with PI (180 degree arc abouve ground)
The sensor event then counts the number of avatars found and prints this via a string. A while loop was used to step through each detected Avatars name, which was then printed to the screen.



No comments:
Post a Comment