Advanced Scripting in Second Life
-
Upload
jeremykemp -
Category
Education
-
view
4.888 -
download
0
description
Transcript of Advanced Scripting in Second Life
Advanced Scripting in Second Life
LIBR 287 - Jeremy Kemp, SJSU [email protected]
HUD points to the WebSteps overview
• Gather the web addresses and icons, resize• Create the “forward” icon and upload images• Upload the script• Test and size the object• Play dice!
Gather web addresses
• Visit the web pages and collect the URLs– www.ala.org– en.wikipedia.org/wiki/Librarian– google.com/search?hl=en&q=librarian– merriam-webster.com/dictionary/librarian
Gather the Icons• Capture icons using a screen capture tool– Google– Wikipedia– ALA– Merriam-Webster– Tool: SnapZPro
• ambrosiasw.com/utilities/snapzprox• Resize to 256/256 (power of 2)– Tool: Photoshop
• adobe.com/products/photoshopCreate • Create the “forward” icon
Upload images
• Bulk upload and pay 50 L$
Create a container with hotspots
Texture them properly
Scripting – What was touched?• ClickedPrim=llDetectedLinkNumber(number);
• if (ClickedPrim==3){ state rotation_three;} else if (ClickedPrim==9){ pageURL="http://google.com/search?hl=en&q=librarian";}
…
An arrow launches state rotation_three which changes the prim’s rotation
Or – the hotspots launch set the URL
Scripting – do that pull down
• llLoadURL(llDetectedKey(0), "Click 'Go To Page' to visit.",pageURL);
llDetectedKey senses the avatar who touched itYou get a nice message on the pulldown
Advanced Scripting 2
Building a simple HUD
Steps overview
• Find the Dice container• Empty it (mostly) and add a blank script• Add the script parts and test it on the ground• Attach to HUD top and resize & position
Clean the dice
• Remove everything but the “dice_drop” sound
• Set “Stretch textures” before resizing• Set the object to nonphysical and .2 on a side
Starting the script
• Two variables that are predefined:– list rots = [<0.00000, 1.00000, 0, 1>,<0.00000, 0, 0.70711, 0.70711>, <-0.00000, 0.00000, -1.00000, 0.00000>, <0.00000, 0.00000, -0.70711, 0.70711>,<0.00000, 0.00000, 0.000, 0.70711>,<0.00000, -1, 0.000, 1>];
– list numbers = [" 一 ","二 ", "三 ", "四 ", "五 ", "六 "];
6 quaternions describe rotation of dice to make each sides show. The list of Chinese numbers is for fun.
Rotation and Eulers
When the prim is born:
default{
state_entry()
{
llSetRot((rotation)llList2String(rots,0));
}
“Set the rotation of the prim to the first item in the list “0”. Notice the type assignment making the string into a rotation.
Prim is touched = set random rot.touch_start(integer total_number)
{integer random = llFloor(llFrand(6.0));
llSetRot((rotation)llList2String(rots,random));
“Take a random number 0 to 6 and round it down (floor)”“Set the rotation of the prim to a random item in the list”
Prim is touched = have some fun
llOwnerSay(llList2String(numbers,random)); llPlaySound("dice_drop”, 1.0);}
}“Use the same random number to pick a
Chinese character and say it to owner.”“Play the sound at volume 1”
Insert the Script
• Make it in your inventory or in the prim• Rename it and add a version number• Copy/Paste the notecard text
Attach to HUD
• Right click> More / Attach HUD / Top