User:Ezian Ecksol
Some Scripts
CamJumper <lsl> // CamJumper // (c) Ezian Ecksol. Use, modify, steal or sale as you like. Keep credits. // // usage: attach anywhere. Say /1 jc // to jump to cam position. works also to neighbour sims. // doesnt work most of the time if flying.
integer jump_max=63; integer chan = 1; key owner;
integer wouldGoOffWorld(vector here, vector there) {
if (there.x < 0. || there.x >= 256. || there.y < 0. || there.y >= 256.) return llEdgeOfWorld(here, there - here); else return FALSE;
}
jumpto(vector to, float time) {
vector e; vector from; vector s; float d; integer i; integer j; vector from0; vector region0; vector region; from = llGetPos();
if (!wouldGoOffWorld(from, to)) {
region0 = llGetRegionCorner()/256.;
do { region = llGetRegionCorner()/256.; if (region != region0) { if (region.x > region0.x) to.x -= 256.; else if (region.x < region0.x) to.x += 256.; if (region.y > region0.y) to.y -= 256.; else if (region.y < region0.y) to.y += 256.; }
from0 = from; region0 = region; d = llVecDist(from, to); j = (integer)(d / jump_max)+1; e = from + (to - from) / (float)j; llOwnerSay("j="+(string)j+", d="+(string)d+", to="+(string)to); llMoveToTarget(e, time); llSleep(.5);
from = llGetPos(); } while ((llVecDist(from, to) > 3.) && (llVecDist(from0, from) > 6.)); llStopMoveToTarget(); } else llOwnerSay("Destination is - or would cross - off-world.");
}
default {
state_entry() { owner = llGetOwner(); llRequestPermissions(owner, PERMISSION_TRACK_CAMERA); }
run_time_permissions(integer perm) { if (perm & PERMISSION_TRACK_CAMERA) llListen(chan, "", owner, "jc");
else llOwnerSay("Did not get permissions, failed."); }
on_rez(integer start_param) { llResetScript(); }
listen(integer ch, string name, key id, string msg) { jumpto(llGetCameraPos() + 3.5 * llRot2Fwd(llGetCameraRot()), .05); }
} </lsl> --Ezian Ecksol 17:21, 23 September 2008 (PDT)
Visitor-Detector
<lsl> // Visitor-Detector 0.66 // (c) Ezian Ecksol. Use, modify, steal or sale as you like. Keep credits.
// modify these values: ///// float ignore_time = 20.; // avatars visiting the parcel less than this time in seconds will be ignored integer print_method = 1; // 0=llSay, 1=llOwnerSay, 2=llInstantMessage float loop_time = 2.; // scanner checks every <loop_time> seconds //////////////////////////////////
vector parcel0; vector parcel1; vector parcel_center; vector parcel_size; float detect_range = 96.; key owner; string parcel; list visitors_long; list visitors_short; integer active;
string getparcelname(vector p) {
return llList2String(llGetParcelDetails(p, [PARCEL_DETAILS_NAME]),0);
}
getparcelbounds() {
vector pos = llGetPos(); vector rpos; pos = <llRound(pos.x), llRound(pos.y), 0.>; string name = getparcelname(pos); rpos = pos; do { rpos.x -= 1.; } while ((getparcelname(rpos) == name) && (rpos.x>=0.)); parcel0.x = rpos.x + 1.; rpos = pos; do { rpos.y -= 1.; } while ((getparcelname(rpos) == name) && (rpos.y>=0.)); parcel0.y = rpos.y + 1.; rpos = pos; do { rpos.x += 1.; } while ((getparcelname(rpos) == name) && (rpos.x<256.)); parcel1.x = rpos.x; rpos = pos; do { rpos.y += 1.; } while ((getparcelname(rpos) == name) && (rpos.y<256.)); parcel1.y = rpos.y; parcel_center = (parcel1 + parcel0) / 2.; parcel_size = parcel1 - parcel0; float c = llPow(parcel_size.x/2.,2.)+llPow(parcel_size.y/2.,2.); float d = detect_range*detect_range; if (c > d) llOwnerSay("Your parcel is to large to be covered by a 96-m-scanner. Place the detector in the middle of the parcel at ground, but the corners are not covered."); else { vector dest = <parcel_center.x, parcel_center.y, llGround(parcel_center-llGetPos())+llSqrt(d-c)>; llOwnerSay("For optimal scanning range at ground, set position of object to: "+Vector2String(dest)); }
}
string format_2dig(integer i) {
if (i<10) return "0"+(string)i; else return (string)i;
}
string format_timestamp(string ts) {
return parcel+", "+llGetSubString(ts, 0, 9)+", "+llGetSubString(ts, 11,18)+" GMT";
}
string format_seconds(integer s) {
integer m = s / 60; s %= 60; integer h = m / 60; m %= 60; return format_2dig(h)+":"+format_2dig(m)+":"+format_2dig(s);
}
console(string txt) {
if (print_method == 0) llSay(0, txt); else if (print_method == 1) llOwnerSay(txt); else llInstantMessage(owner, txt);
}
visitors_left(list v) {
integer j = llGetListLength(v); if (j) { integer i; integer tu = llGetUnixTime(); for (i=0; i<j; i+=3) console("<< "+llList2String(v, i)+" left "+parcel+" after "+format_seconds(tu-llList2Integer(v, i+1))); }
}
string Float2String(float num) {
list s = llParseString2List((string)(llRound(num*10.)/10.), ["."], []); return llList2String(s, 0)+"."+llGetSubString(llList2String(s, 1), 0, 0);
}
string Vector2String(vector v) {
return "<"+Float2String(v.x)+", "+Float2String(v.y)+", "+Float2String(v.z)+">";
}
activate(integer a) {
active = a; if (a) { llOwnerSay("Scans every "+Float2String(loop_time)+"s. Ignores visitors staying less than "+Float2String(ignore_time)+"s."); llOwnerSay("Activated: "+format_timestamp(llGetTimestamp())); llSensorRepeat("", NULL_KEY, AGENT, detect_range, PI, loop_time); } else { llOwnerSay("Deactived."); llSensorRemove(); }
}
default {
state_entry() { owner = llGetOwner(); parcel = "\""+llList2String(llGetParcelDetails(llGetPos(), [PARCEL_DETAILS_NAME]),0)+"\""; // +" in "+llGetRegionName(); activate(TRUE); llOwnerSay("Touch to stop or start."); getparcelbounds(); } touch_start(integer n) { if (llDetectedKey(0) == owner) activate(!active); } on_rez(integer p) { llResetScript(); } changed(integer c) { if (c & CHANGED_OWNER) llResetScript(); }
sensor(integer n) { integer i; integer j; integer tu = llGetUnixTime(); string ts = llGetTimestamp(); string dname; list temp; list temp_short = visitors_short; list temp_long = visitors_long; visitors_short = []; visitors_long = [];
for (i=0; i<n; ++i) { if (llOverMyLand(llDetectedKey(i))) { //vector dpos = llDetectedPos(i); //if ((dpos.x >= parcel0.x) && (dpos.x < parcel1.x) && (dpos.y >= parcel0.y) && (dpos.y < parcel1.y)) { dname = llDetectedName(i); j = llListFindList(temp_long, [dname]); if (j != -1) { visitors_long += llList2List(temp_long, j, j+2); temp_long = llDeleteSubList(temp_long, j, j+2); } else { j = llListFindList(temp_short, [dname]); if (j != -1) { temp = llList2List(temp_short, j, j+2); if ((tu-llList2Integer(temp, 1)) >= ignore_time) { visitors_long += temp; console(">> "+llList2String(temp, 0)+" entered "+format_timestamp(llList2String(temp, 2)));
} else { visitors_short += temp; } } else { visitors_short += [dname, tu, ts]; } } } } visitors_left(temp_long); } no_sensor() { visitors_left(visitors_long); visitors_short = []; visitors_long = []; }
} </lsl>
1-Prim Digiclock
<lsl>// 1-Prim Digiclock // (c) Ezian Ecksol, open source, keep credits // // put to object description the GMT offset in hours, e.g 2.5 // touch to turn on/off
list faces = [3,2.05,.6, 7,.795,0., 4,-11.5,-0.73, 6,.795,0., 1,2.05,-0.6]; key tx = "2b43c7d6-c96a-b5d9-7210-8bc15451252f"; float tx_step = 0.0625; float tx_step_2; float tx_base; integer presence0; float gmt_offset; float clock_cycle; float clock_time; integer clock_mode = TRUE;
list construct_face(integer f, integer z) {
integer i = f*3; return [PRIM_TEXTURE, llList2Integer(faces,i), tx, <llList2Float(faces,i+1), tx_step, 0.0>, <llList2Float(faces,i+2), tx_base-(float)z*tx_step, 0.0>, 0.0];
}
setprim(integer z1, integer z2, integer z3, integer z4, integer z5) {
llSetPrimitiveParams( construct_face(0,z1)+construct_face(1,z2)+ construct_face(2,z3)+construct_face(3,z4)+ construct_face(4,z5));
}
clock() {
clock_time = llGetGMTclock() + gmt_offset*3600.0; integer s = (integer) clock_time; integer h = (s / 3600) % 24; integer m = s % 3600; m = m / 60; setprim(h/10,h%10,10,m/10,m%10); llResetTime();
integer w1 = (integer) (clock_time / clock_cycle); float w2 = clock_time - (float)w1 * clock_cycle; llSetTimerEvent(clock_cycle-w2);
}
default {
state_entry() { integer f; integer i; list j; gmt_offset = (float)llGetObjectDesc(); tx_step_2 = tx_step / 2.; tx_base = 0.5 - tx_step_2; clock_cycle = 60.0; setprim(11,11,11,11,11); for (i=0; i<15; i+=3) { f = llList2Integer(faces,i); j += [PRIM_GLOW,f,.01, PRIM_COLOR, f, <0., 0., 1.>, 1.]; } llSetPrimitiveParams([ PRIM_TYPE, PRIM_TYPE_PRISM, 1, <0.2, 0.8, 0.0>, 0.7, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, PRIM_SIZE, <0.01, 1.777, 0.577>, PRIM_FULLBRIGHT, ALL_SIDES, TRUE, PRIM_COLOR, ALL_SIDES, <0., 0., 1.>, 0.] + j); clock(); } on_rez(integer p) { llResetScript(); }
touch_start(integer total_number) { if (llGetOwner() == llDetectedKey(0)) { clock_mode = !clock_mode; if (clock_mode) { clock(); } else { llSetTimerEvent(0.); setprim(15,15,15,15,15); } } } timer() { clock(); }
}</lsl> --Ezian Ecksol 17:21, 23 September 2008 (PDT)
Cam Lock/Follow <lsl> // Camstyle, (c) Ezian Ecksol, feel free to copy, steal, modify
// Put script into prim, attach it. // usage: position your camera where you like. // enter in chan: // /1 camstyle follow <-- camera is fixed, but follows your av // /1 camstyle lock <-- camera is completly locked // /1 camstyle <-- releases cam again
integer chan = 1;
key owner; list keywords = ["lock", "follow"];
cam_style(integer cs) {
llRequestPermissions(owner, PERMISSION_CONTROL_CAMERA | PERMISSION_TRACK_CAMERA); llClearCameraParams(); if (!cs) return; vector cpos = llGetCameraPos(); list params = [CAMERA_ACTIVE, TRUE, CAMERA_POSITION_LOCKED, TRUE, CAMERA_POSITION_THRESHOLD, 0.5, CAMERA_FOCUS_THRESHOLD, 0.5, CAMERA_POSITION, cpos]; if (cs == 1) params += [ CAMERA_DISTANCE, .5, // ( 0.5 to 10) meters CAMERA_BEHINDNESS_LAG, 0.1, // (0 to 3) seconds CAMERA_PITCH, 10.0, // (-45 to 80) degrees CAMERA_FOCUS, cpos + llRot2Fwd(llGetCameraRot()), // region-relative position CAMERA_FOCUS_LAG, 0.1, // (0 to 3) seconds CAMERA_FOCUS_LOCKED, TRUE, // (TRUE or FALSE) CAMERA_POSITION_LAG, 1.0 // (0 to 3) seconds ]; else if (cs == 2) params += [ CAMERA_FOCUS_LAG, 0.0, // (0 to 3) seconds CAMERA_BEHINDNESS_LAG, 0.5 // (0 to 3) seconds
]; llSetCameraParams(params);
}
default {
state_entry() { owner = llGetOwner(); llListen(chan, "", owner, ""); } listen(integer channel, string name, key id, string msg) { msg = llToLower(msg); list m = llParseString2List(msg, [" "], []); if (llList2String(m, 0) == "camstyle") cam_style(llListFindList(keywords, [llList2String(m, 1)]) + 1); }
changed(integer c) { if (c & CHANGED_OWNER) llResetScript(); }
} </lsl> --Ezian Ecksol 17:21, 23 September 2008 (PDT)