You are on page 1of 17

Week Of Learning

October 2008
“New Scripting Options
with 1.21 Browser”
Salahzar Stenvaag
Previous Scripting Improvements
in 2007-2008

2007: Introduction of Sculpted Prims, Voice and


WindLight (no major scripting improvements)

2008: Havok & New media streaming


possibilities including a limited URL on PRIM

October 2008: New MONO engine and new


touch&detect lsl functions.

December 2008: New HttpServer lsl function?


New Mono Engine

● It is NATIVE (should be very FAST)


● Memory 16K => 64K (more memory, less linked

messages)
● Special detect features so you can do more

professional vendors, and tools like boards (this


lesson)
● Compatible scripts lsl2

● llGetRegionAgentCount & llGetAgentLanguage()


llDetectedTouch* family

● LlDetectedTouchFace (which face?)


● llDetectedTouchUV & llDetectedTouchST (which

x,y position? UV is relating to prim face, ST relating


to original texture. If scale is 1,1 they are =
● llDetectedTouchPos (which position in the sim)

● LlDetectedTouchNormal (for pushing)

● LlDetectedTouchBinormal (tangent)

=> We will use the "red ones" for this class.


ToolBox implementation
6x6 buttons

You can find this in


the folder
"Class 1.21 - New
Scripting Features"
The Script
Clickable Map

This helps you in


finding out x,y to be
Used in
llDetectedTouchST
Base Script (sending base scale)

Simply needs to send its current

● position,
● rotation and

● Scale

To the glass so that glass when resized can


easily compute coordinates to be put in if
Base Script (sending base scale)
touch_start(integer total_number) {
vector
sendInfo() 1 st=llDetectedTouchST(0);
{
if( (st.x>=0.278086) &&
// inform of my pos, rot and
(st.x<=0.417826) && 2
scale
llSay(1000,llList2CSV([llGetP (st.y>=0.726975) &&
os(),llGetRot(),llGetScale()])); (st.y<=0.868637) ) {
} llSay(0,"In Lombardia!");
default }
{ sendInfo();
state_entry() }
{ changed(integer change) {
llSay(0, "Reset"); if(change & CHANGED_SCALE)
sendInfo(); {
} // send the scale info to all
children
sendInfo();
3
}
Glass Script

Needs to listen for the

● position,
● rotation and

● Scale

Of the base. When resized or touched should


compute smartly coordinates
Modifiable Glass (1)
saying computed coordinates
vector x1=ZERO_VECTOR; vector x2=llGetPos();
rotation vector s2=llGetScale();
r1=ZERO_ROTATION; topleft=(x2-(s2/2.0))-f; 2
vector s1=ZERO_VECTOR; topleft.x=1-topleft.x/s1.x;
vector f=ZERO_VECTOR; topleft.z=topleft.z/s1.z;
bottomright=x2+(s2/2.0)-f;
vector topleft; bottomright.x=1-bottomright.x/s1.x;
vector bottomright; bottomright.z=bottomright.z/s1.z;
Say() { llSay(0,"if( (st.x>="+
if(x1==ZERO_VECTOR) { (string)bottomright.x+") &&
llSay(0,"Must transmit (st.x<="+(string)topleft.x+") &&
localrootscale"); (st.y>="+(string)topleft.z+") &&
return; (st.y<="+(string)bottomright.z+")");
} 1
}
Modifiable Glass (2)
listener to base and to touches
Default { listen(integer channel, string name,
state_entry() { key id, string str) {
llSay(0, "Reset!"); list recvd=llCSV2List(str);
llListen(1000,"",NULL_KEY,"" x1=(vector)llList2String(recvd,0);
); r1=(rotation)llList2String(recvd,1);
} s1=(vector)llList2String(recvd,2);
touch_start(integer
number) { f=x1-s1/2;
say();
} } 2
changed(integer change) { }
say();
}
1
Highlightable board

This helps you


In highlighting
Slides,
Videos,
And whatever
:)
Board Script

Toggles each touch.


1st touch will set top-left corner to
highlight
nd

2 touch will define bottom-right corner
and will send a message to the glass
Board Script (toggling and sending
nd
info at 2 touch
default
integer status=0; {
vector st1; state_entry()
vector st2; 1 {
2
sendInfo() llSay(0, "Reset");
{ status=0;
// inform of my touched }
pos, pos, rot and scale
touch_start(integer total_number) {
if(status==0) {
llMessageLinked(LINK_SET,0
st1=llDetectedTouchST(0);
,llList2CSV([st1, st2,
llSay(0,"click for 2nd point");
llGetPos(),llGetRot(),llGetSca
status++;
le()]), NULL_KEY);
return;
}
}
st2=llDetectedTouchST(0); 3
sendInfo(); status=0;
llSay(0,"Click for next 1st
point"); } }
Glass
Flashing and receiving resizing pos
Glass must:

● 1. Flash to be clearly visible

● 2. Receive information from base

● 3. Resize accordingly
Glass Script flashing and resizing
integer st=0;
vector x1=ZERO_VECTOR; default {
rotation r1=ZERO_ROTATION; state_entry() { llSetTimerEvent(1); }1
vector s1=ZERO_VECTOR; timer() {
vector f=ZERO_VECTOR; if(st==0) llSetAlpha(0.1,ALL_SIDES);
vector st1=ZERO_VECTOR; else llSetAlpha(0.5,ALL_SIDES);
vector st2=ZERO_VECTOR; st=1-st; // toggle flashing alpha
vector s2=ZERO_VECTOR; }} s2.x=(st2.x-st1.x)*s1.x;
2 s2.y=0.1;
default {
s2.z=(st1.y-st2.y)*s1.z; 3
link_message(integer sender, integer
vector x2=llGetPos();
channel, string str, key id){
x2.x=-s1.x/2+s1.x*(1-st1.x)-s2.x/2;
list recvd=llCSV2List(str);
x2.y=0;
st1=(vector)llList2String(recvd,0);
x2.z=-s1.z/2+s1.z*(st1.y)-s2.z/2;
st2=(vector)llList2String(recvd,1);
llSetScale(s2);
x1=(vector)llList2String(recvd,2);
llSetPos(x2);
r1=(rotation)llList2String(recvd,3);
f=x1-s1/2;
s1=(vector)llList2String(recvd,4);
}}

You might also like