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.
Friday, 30 September 2011
Thursday, 29 September 2011
Week 1
The Second Task was even easier. We had to script so that a Prim would announce how many times it was tocuhed. No restrictions or loops were needed for this. Just the ++ fucntion. the Integer had to be declared globally.
Week 1 consisted of basic LSL scripting and touch interactions with Prims.
First task was to create a Prim that would state the Avatars name and count to 10. Using the command llGetDisplayName and llDetectedKey it was possilbe to broadcast this on channel 0 (Could also use llOwnerSay if I just wanted to boradcast to myself.
Next using a do while loop and the ++ function, it was possible to count to 10 (setting parameters to a <11)
The Second Task was even easier. We had to script so that a Prim would announce how many times it was tocuhed. No restrictions or loops were needed for this. Just the ++ fucntion. the Integer had to be declared globally.
Subscribe to:
Posts (Atom)



