Advanced Scripting in Second Life

19
Advanced Scripting in Second Life LIBR 287 - Jeremy Kemp, SJSU SLIS [email protected]

description

Shows the process to create a heads up display

Transcript of Advanced Scripting in Second Life

Page 1: Advanced Scripting in Second Life

Advanced Scripting in Second Life

LIBR 287 - Jeremy Kemp, SJSU [email protected]

Page 2: Advanced Scripting in Second Life

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!

Page 3: Advanced Scripting in Second Life

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

Page 4: Advanced Scripting in Second Life

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

Page 5: Advanced Scripting in Second Life

Upload images

• Bulk upload and pay 50 L$

Page 6: Advanced Scripting in Second Life

Create a container with hotspots

Page 7: Advanced Scripting in Second Life

Texture them properly

Page 8: Advanced Scripting in Second Life

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

Page 9: Advanced Scripting in Second Life

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

Page 10: Advanced Scripting in Second Life

Advanced Scripting 2

Building a simple HUD

Page 11: Advanced Scripting in Second Life

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

Page 12: Advanced Scripting in Second Life

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

Page 13: Advanced Scripting in Second Life

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.

Page 14: Advanced Scripting in Second Life

Rotation and Eulers

Page 15: Advanced Scripting in Second Life

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.

Page 16: Advanced Scripting in Second Life

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”

Page 17: Advanced Scripting in Second Life

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”

Page 18: Advanced Scripting in Second Life

Insert the Script

• Make it in your inventory or in the prim• Rename it and add a version number• Copy/Paste the notecard text

Page 19: Advanced Scripting in Second Life

Attach to HUD

• Right click> More / Attach HUD / Top