diff --git a/LSL/CameraButton.lsl b/LSL/CameraButton.lsl index bc785cd..b440070 100644 --- a/LSL/CameraButton.lsl +++ b/LSL/CameraButton.lsl @@ -1,7 +1,19 @@ -// LSL script generated: Camera.LSL.CameraButton.lslp Mon Mar 10 13:50:44 Mitteleuropäische Zeit 2014 +// LSL script generated: Camera.LSL.CameraButton.lslp Mon Mar 10 18:20:21 Mitteleuropäische Zeit 2014 + + + + default { - touch_start(integer total_number) { + state_entry() { + integer rc = 0; + (rc = llSetMemoryLimit(8192)); + + } + + + + touch_start(integer num_detected) { llMessageLinked(1,0,"cam",llDetectedKey(0)); } } diff --git a/LSL/CameraButton.lslp b/LSL/CameraButton.lslp index 8e12eb2..5cc6a63 100644 --- a/LSL/CameraButton.lslp +++ b/LSL/CameraButton.lslp @@ -1,8 +1,25 @@ +integer verbose = FALSE; + +string g_sTitle = "CameraScript-Button"; // title +string g_sVersion = "1.11"; // version +string g_sScriptName; + + +$import MemoryManagement2.lslm(m_sTitle=g_sTitle, m_sScriptName=g_sScriptName, m_iVerbose=verbose); + + + default { - touch_start(integer total_number) - { - llMessageLinked(LINK_ROOT, 0, "cam", llDetectedKey(0)); - } -} + state_entry() + { + //g_sScriptName = llGetScriptName(); + MemRestrict(8192, FALSE); + } + + touch_start(integer num_detected) + { + llMessageLinked(LINK_ROOT, 0, "cam", llDetectedKey(0)); + } +} \ No newline at end of file diff --git a/LSL/CameraScript.lsl b/LSL/CameraScript.lsl index 4c3b7a6..5b33d35 100644 --- a/LSL/CameraScript.lsl +++ b/LSL/CameraScript.lsl @@ -1,4 +1,4 @@ -<<<<<<< HEAD +// LSL script generated: Camera.LSL.CameraScript.lslp Mon Mar 10 18:43:18 Mitteleuropäische Zeit 2014 /////////////////////////////////////////////////////////////////////////////////////////////////// //Camera Control // @@ -10,585 +10,52 @@ //Search script for "changedefault" to find the line you need to alter to change the default view you see when first attaching the HUD! // //parts from: -// Script Vitality - keeps the script itself and all scripts in same prim +// Script Vitality - keeps the script itself and all scripts in same prim // running also in 'dead' areas, those areas where scrpts are not allowed. -// This works simply by taking avatar controls. +// This works simply by taking avatar controls. // Author Jenna Felton // Version 1.0 - +// //modified by: Zopf Resident - Ray Zopf (Raz) //Additions: when reusing some older code -//04. Jan. 2014 -//v1.0 +//10. Mrz. 2014 +//v1.21 +// //Files: //CameraScript.lsl +// //NAME OF NOTEDACRD // // -//Prequisites: --- -//Notecard format: when storing settings -//basic help: +//Prequisites: ---- +//Notecard format: ---- +//basic help: ---- // - //Changelog -// NOTECARD NAME, LINK, GIT, SHORT DESCRIPTION, ETC. -// TEXT +// Formatting -//bug: +//FIXME: llListens() - too many listeners -//todo: -// +//TODO: ---- /////////////////////////////////////////////////////////////////////////////////////////////////// -//=============================================== -//FIRESTORM SPECIFIC DEBUG STUFF -//=============================================== - -//#define FSDEBUG -//#include "fs_debug.lsl" - - //=============================================== //GLOBAL VARIABLES //=============================================== -//debug variables -//----------------------------------------------- -integer g_iDebugMode=FALSE; // set to TRUE to enable Debug messages - - //user changeable variables //----------------------------------------------- -integer g_iVerbose = TRUE; // show more/less info during startup +integer verbose; //internal variables //----------------------------------------------- -string g_sTitle = "SCRIPT NAME"; // title -string g_sVersion = "VERSION NUMBER"; // version +string g_sTitle = "CameraScript"; +string g_sVersion = "1.21"; string g_sScriptName; - - -// Constants -integer iCONSTANT; - -//SCRIPT MESSAGE MAP - - -// Variables -key g_kOwner; // object owner -key g_kUser; // key of last avatar to touch object -key g_kQuery = NULL_KEY; - -integer CHANNEL; // dialog channel -list MENU_MAIN = ["Centre", "Right", "Left", "Cam ON", "Cam OFF"]; // the main menu -list MENU_2 = ["More...", "...Back"]; // menu 2 - -integer on = FALSE; -integer flying; -integer falling; -integer spaz = 0; -integer trap = 0; - -//=============================================== -//PREDEFINED FUNCTIONS -//=============================================== - -//=============================================================================== -//= parameters : string sMsg message string received -//= -//= return : none -//= -//= description : output debug messages -//= -//=============================================================================== -Debug(string sMsg) -{ - if (!g_iDebugMode) return; - llOwnerSay("DEBUG: "+ g_sScriptName + "; " + sMsg); -} - -//most important function -//----------------------------------------------- - -take_camera_control(key agent) -{ - llOwnerSay("take_camera_control"); // say function name for debugging - llOwnerSay( (string)agent); - llRequestPermissions(agent, PERMISSION_CONTROL_CAMERA); - llSetCameraParams([CAMERA_ACTIVE, 1]); // 1 is active, 0 is inactive - on = TRUE; -} - -release_camera_control(key agent) -{ - llOwnerSay("release_camera_control"); // say function name for debugging - llSetCameraParams([CAMERA_ACTIVE, 0]); // 1 is active, 0 is inactive - llReleaseCamera(agent); - on = FALSE; -} - -focus_on_me() -{ - llOwnerSay("focus_on_me"); // say function name for debugging - // llClearCameraParams(); // reset camera to default - vector here = llGetPos(); - llSetCameraParams([ - CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive - CAMERA_BEHINDNESS_ANGLE, 0.0, // (0 to 180) degrees - CAMERA_BEHINDNESS_LAG, 0.0, // (0 to 3) seconds - CAMERA_DISTANCE, 0.0, // ( 0.5 to 10) meters - CAMERA_FOCUS, here, // region relative position - CAMERA_FOCUS_LAG, 0.0 , // (0 to 3) seconds - CAMERA_FOCUS_LOCKED, TRUE, // (TRUE or FALSE) - CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) meters -// CAMERA_PITCH, 80.0, // (-45 to 80) degrees - CAMERA_POSITION, here + <4.0,4.0,4.0>, // region relative position - CAMERA_POSITION_LAG, 0.0, // (0 to 3) seconds - CAMERA_POSITION_LOCKED, TRUE, // (TRUE or FALSE) - CAMERA_POSITION_THRESHOLD, 0.0, // (0 to 4) meters - CAMERA_FOCUS_OFFSET, ZERO_VECTOR // <-10,-10,-10> to <10,10,10> meters - ]); -} - -default_cam() -{ -// llOwnerSay("default_cam"); // say function name for debugging - llClearCameraParams(); // reset camera to default - llSetCameraParams([CAMERA_ACTIVE, 1]); - - -} - - -shoulder_cam2() -{ - llOwnerSay("Right Shoulder"); // say function name for debugging - default_cam(); - llSetCameraParams([ - CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive - CAMERA_BEHINDNESS_ANGLE, 0.0, // (0 to 180) degrees - CAMERA_BEHINDNESS_LAG, 0.0, // (0 to 3) seconds - CAMERA_DISTANCE, 0.5, // ( 0.5 to 10) meters - //CAMERA_FOCUS, <0.0,0.0,5.0>, // region relative position - CAMERA_FOCUS_LAG, 0.01 , // (0 to 3) seconds - CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE) - CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) meters - CAMERA_PITCH, 15.0, // (-45 to 80) degrees - //CAMERA_POSITION, <0.0,0.0,0.0>, // region relative position - CAMERA_POSITION_LAG, 0.1, // (0 to 3) seconds - CAMERA_POSITION_LOCKED, FALSE, // (TRUE or FALSE) - CAMERA_POSITION_THRESHOLD, 0.0, // (0 to 4) meters - CAMERA_FOCUS_OFFSET, <-0.5,-0.5,0.75> // <-10,-10,-10> to <10,10,10> meters - ]); -} - - -shoulder_cam() -{ - llOwnerSay("shoulder_cam"); // say function name for debugging - default_cam(); - llSetCameraParams([ - CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive - CAMERA_BEHINDNESS_ANGLE, 5.0, // (0 to 180) degrees - CAMERA_BEHINDNESS_LAG, 0.0, // (0 to 3) seconds - CAMERA_DISTANCE, 0.5, // ( 0.5 to 10) meters - //CAMERA_FOCUS, <0.0,0.0,5.0>, // region relative position - CAMERA_FOCUS_LAG, 0.01 , // (0 to 3) seconds - CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE) - CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) meters - CAMERA_PITCH, 15.0, // (-45 to 80) degrees - //CAMERA_POSITION, <0.0,0.0,0.0>, // region relative position - CAMERA_POSITION_LAG, 0.1, // (0 to 3) seconds - CAMERA_POSITION_LOCKED, FALSE, // (TRUE or FALSE) - CAMERA_POSITION_THRESHOLD, 0.0, // (0 to 4) meters - CAMERA_FOCUS_OFFSET, <-0.5,-0.5,0.75> // <-10,-10,-10> to <10,10,10> meters - ]); -} - -shoulder_cam3() -{ - llOwnerSay("Left Shoulder"); // say function name for debugging - default_cam(); - llSetCameraParams([ - CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive - CAMERA_BEHINDNESS_ANGLE, 5.0, // (0 to 180) degrees - CAMERA_BEHINDNESS_LAG, 0.0, // (0 to 3) seconds - CAMERA_DISTANCE, 0.5, // ( 0.5 to 10) meters - //CAMERA_FOCUS, <0.0,0.0,5.0>, // region relative position - CAMERA_FOCUS_LAG, 0.01 , // (0 to 3) seconds - CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE) - CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) meters - CAMERA_PITCH, 15.0, // (-45 to 80) degrees - //CAMERA_POSITION, <0.0,0.0,0.0>, // region relative position - CAMERA_POSITION_LAG, 0.1, // (0 to 3) seconds - CAMERA_POSITION_LOCKED, FALSE, // (TRUE or FALSE) - CAMERA_POSITION_THRESHOLD, 0.0, // (0 to 4) meters - CAMERA_FOCUS_OFFSET, <-0.5,0.5,0.75> // <-10,-10,-10> to <10,10,10> meters - ]); -} - -centre_cam() -{ - llOwnerSay("centre_cam"); // say function name for debugging - default_cam(); - llSetCameraParams([ - CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive - CAMERA_BEHINDNESS_ANGLE, 0.0, // (0 to 180) degrees - CAMERA_BEHINDNESS_LAG, 0.0, // (0 to 3) seconds - CAMERA_DISTANCE, 0.5, // ( 0.5 to 10) meters - //CAMERA_FOCUS, <0.0,0.0,5.0>, // region relative position - CAMERA_FOCUS_LAG, 0.01 , // (0 to 3) seconds - CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE) - CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) meters - CAMERA_PITCH, 15.0, // (-45 to 80) degrees - //CAMERA_POSITION, <0.0,0.0,0.0>, // region relative position - CAMERA_POSITION_LAG, 0.1, // (0 to 3) seconds - CAMERA_POSITION_LOCKED, FALSE, // (TRUE or FALSE) - CAMERA_POSITION_THRESHOLD, 0.0, // (0 to 4) meters - CAMERA_FOCUS_OFFSET, <-0.5,0,0.75> // <-10,-10,-10> to <10,10,10> meters - ]); -} - - -drop_camera_5_seconds() -{ - llOwnerSay("drop_camera_5_seconds"); // say function name for debugging - llSetCameraParams([ - CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive - CAMERA_BEHINDNESS_ANGLE, 0.0, // (0 to 180) degrees - CAMERA_BEHINDNESS_LAG, 0.5, // (0 to 3) seconds - CAMERA_DISTANCE, 3.0, // ( 0.5 to 10) meters - //CAMERA_FOCUS, <0.0,0.0,5.0>, // region relative position - CAMERA_FOCUS_LAG, 2.0, // (0 to 3) seconds - CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE) - CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) meters - CAMERA_PITCH, 0.0, // (-45 to 80) degrees - //CAMERA_POSITION, <0.0,0.0,0.0>, // region relative position - CAMERA_POSITION_LAG, 0.05, // (0 to 3) seconds - CAMERA_POSITION_LOCKED, TRUE, // (TRUE or FALSE) - CAMERA_POSITION_THRESHOLD, 0.0, // (0 to 4) meters - CAMERA_FOCUS_OFFSET, <0.0,0.0,0.0> // <-10,-10,-10> to <10,10,10> meters - ]); - llSleep(5); - default_cam(); -} - - - -worm_cam() -{ - llOwnerSay("worm_cam"); // say function name for debugging - llSetCameraParams([ - CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive - CAMERA_BEHINDNESS_ANGLE, 180.0, // (0 to 180) degrees - CAMERA_BEHINDNESS_LAG, 0.0, // (0 to 3) seconds - CAMERA_DISTANCE, 8.0, // ( 0.5 to 10) meters - //CAMERA_FOCUS, <0.0,0.0,5.0>, // region relative position - CAMERA_FOCUS_LAG, 0.0 , // (0 to 3) seconds - CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE) - CAMERA_FOCUS_THRESHOLD, 4.0, // (0 to 4) meters - CAMERA_PITCH, -45.0, // (-45 to 80) degrees - //CAMERA_POSITION, <0.0,0.0,0.0>, // region relative position - CAMERA_POSITION_LAG, 1.0, // (0 to 3) seconds - CAMERA_POSITION_LOCKED, FALSE, // (TRUE or FALSE) - CAMERA_POSITION_THRESHOLD, 1.0, // (0 to 4) meters - CAMERA_FOCUS_OFFSET, <0.0,0.0,0.0> // <-10,-10,-10> to <10,10,10> meters - ]); -} - -spaz_cam() -{ - llOwnerSay("spaz_cam for 5 seconds"); // say function name for debugging - float i; - for (i=0; i< 50; i+=1) - { - vector xyz = llGetPos() + ; - // llOwnerSay((string)xyz); - vector xyz2 = llGetPos() + ; - llSetCameraParams([ - CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive - CAMERA_BEHINDNESS_ANGLE, 180.0, // (0 to 180) degrees - CAMERA_BEHINDNESS_LAG, llFrand(3.0), // (0 to 3) seconds - CAMERA_DISTANCE, llFrand(10.0), // ( 0.5 to 10) meters - //CAMERA_FOCUS, xyz, // region relative position - CAMERA_FOCUS_LAG, llFrand(3.0), // (0 to 3) seconds - CAMERA_FOCUS_LOCKED, TRUE, // (TRUE or FALSE) - CAMERA_FOCUS_THRESHOLD, llFrand(4.0), // (0 to 4) meters - CAMERA_PITCH, llFrand(125.0) - 45, // (-45 to 80) degrees - CAMERA_POSITION, xyz2, // region relative position - CAMERA_POSITION_LAG, llFrand(3.0), // (0 to 3) seconds - CAMERA_POSITION_LOCKED, TRUE, // (TRUE or FALSE) - CAMERA_POSITION_THRESHOLD, llFrand(4.0), // (0 to 4) meters - CAMERA_FOCUS_OFFSET, // <-10,-10,-10> to <10,10,10> meters - ]); - llSleep(0.1); - } - default_cam(); -} - -spin_cam() -{ - llSetCameraParams([ - CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive - CAMERA_BEHINDNESS_ANGLE, 180.0, // (0 to 180) degrees - CAMERA_BEHINDNESS_LAG, 0.5, // (0 to 3) seconds - //CAMERA_DISTANCE, 10.0, // ( 0.5 to 10) meters - //CAMERA_FOCUS, <0.0,0.0,5.0>, // region relative position - CAMERA_FOCUS_LAG, 0.05 , // (0 to 3) seconds - CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE) - CAMERA_FOCUS_THRESHOLD, 0.0, // (0 to 4) meters - CAMERA_PITCH, 30.0, // (-45 to 80) degrees - //CAMERA_POSITION, <0.0,0.0,0.0>, // region relative position - CAMERA_POSITION_LAG, 0.0, // (0 to 3) seconds - CAMERA_POSITION_LOCKED, FALSE, // (TRUE or FALSE) - CAMERA_POSITION_THRESHOLD, 0.0, // (0 to 4) meters - CAMERA_FOCUS_OFFSET, <0.0,0.0,0.0> // <-10,-10,-10> to <10,10,10> meters - ]); - - float i; - vector camera_position; - for (i=0; i< 2*TWO_PI; i+=.05) - { - camera_position = llGetPos() + <0.0, 4.0, 0.0> * llEuler2Rot(<0.0, 0.0, i>); - llSetCameraParams([CAMERA_POSITION, camera_position]); - } - default_cam(); -} - -setup_listen() -{ - llListenRemove(1); - CHANNEL = -50000 -llRound(llFrand(1) * 100000); - integer x = llListen(CHANNEL, "", "", ""); // listen for dialog answers -} - - -//=============================================== -//=============================================== -//MAIN -//=============================================== -//=============================================== - -//----------------------------------------------- - -default -{ - - state_entry() { - g_kOwner = llGetOwner(); - g_sScriptName = llGetScriptName(); - - Debug((string)llGetFreeMemory() + " bytes free"); - llWhisper(0, g_sTitle +" ("+ g_sVersion +") Enhancements by Zopf"); - llWhisper(0, "INSTRUCTIONS"); - if (g_iVerbose) llWhisper(0, "Loading notecard..."); - ; - } - - on_rez(integer i) { - ; - } - - changed(integer change) { - if(change & CHANGED_INVENTORY) ; - if(change & CHANGED_REGION) ; - if(change & CHANGED_OWNER) llResetScript(); - } - -//let it run in noscript areas -//----------------------------------------------- - run_time_permissions(integer perms) { - if (perms & PERMISSION_TAKE_CONTROLS) { - llOwnerSay("Automatic Group Changer runs in noscript-areas"); - llTakeControls(CONTROL_DOWN, TRUE, TRUE); - } - } - - // This is the magic. Even if empty the event handler makes the script - // to keep the avatar's control. The script itself does not use it. - control(key name, integer levels, integer edges) - { - ; - } - - //make sure that we always have permissions - timer() { - if(llGetPermissions() & PERMISSION_TAKE_CONTROLS) return; - llRequestPermissions(kOwner, PERMISSION_TAKE_CONTROLS); - } - - - state_entry() - { - llSitTarget(<0.0, 0.0, 0.1>, ZERO_ROTATION); - setup_listen(); - llSetTimerEvent(2.0); - } - -//listen for linked messages from other RealFire scripts and devices -//----------------------------------------------- - link_message(integer sender_num, integer num, string str, key id) - { - if(str == "cam") - { - integer perm = llGetPermissions(); - if (perm & PERMISSION_CONTROL_CAMERA) - llDialog(id, "What do you want to do?", MENU_MAIN, CHANNEL); // present dialog on click - } - } - -//user interaction -//listen to usercommands -//----------------------------------------------- - listen(integer channel, string name, key id, string message) - { - if (~llListFindList(MENU_MAIN + MENU_2, [message])) // verify dialog choice -// if (~llListFindList(MENU_MAIN, [message])) // verify dialog choice - { -// llOwnerSay(name + " picked the option '" + message + "'."); // output the answer - if (message == "More...") - llDialog(id, "Pick an option!", MENU_2, CHANNEL); // present submenu on request - else if (message == "...Back") - llDialog(id, "What do you want to do?", MENU_MAIN, CHANNEL); // present main menu on request to go back - - - else if (message == "Cam ON") - { - take_camera_control(id); - } - - else if (message == "Cam OFF") - { - release_camera_control(id); - } - - else if (message == "Default") - { - default_cam(); - } - - else if (message == "Right") - { - shoulder_cam2(); - } - - else if (message == "Worm Cam") - { - worm_cam(); - } - - else if (message == "Centre") - { - centre_cam(); - } - - else if (message == "Left") - { - shoulder_cam3(); - } - - else if (message == "Shoulder") - { - shoulder_cam(); - } - - else if (message == "Drop Cam") - { - drop_camera_5_seconds(); - } - - else if (message == "Trap Toggle") - { - trap = !trap; - if (trap == 1) { - llOwnerSay("trap is on"); - } - else { - llOwnerSay("trap is off"); - } - } - - else if (message == "Spin Cam") - { - spin_cam(); - } - - } else - llOwnerSay(name + " picked invalid option '" + llToLower(message) + "'."); // not a valid dialog choice - } - - run_time_permissions(integer perm) { - if (perm & PERMISSION_CONTROL_CAMERA) { - llSetCameraParams([CAMERA_ACTIVE, 1]); // 1 is active, 0 is inactive - llOwnerSay("Camera permissions have been taken"); - } - } - - changed(integer change) - { - if (change & CHANGED_LINK) - { - key agent = llAvatarOnSitTarget(); - if (agent) - { - setup_listen(); - llRequestPermissions(agent, PERMISSION_CONTROL_CAMERA); - } - } - } - - attach(key agent) - { - if (agent) - { - setup_listen(); - llRequestPermissions(agent, PERMISSION_CONTROL_CAMERA); - shoulder_cam(); - //changedefault The above is what you need to change to change the default camera view you see whenever you first attach the HUD. For example, change it to centre_cam(); to have the default view be centered behind your avatar! - } - } - - timer() - { - if (trap == 1) - { - focus_on_me(); - } - } - -//----------------------------------------------- -//END STATE: default -//----------------------------------------------- -} -======= -// LSL script generated: Camera.LSL.CameraScript.lslp Sun Mar 9 21:52:54 Mitteleuropäische Zeit 2014 -/////////////////////////////////////////////////////////////////////////////////////////////////// -//Camera Control -// -//parts from: -//Original Camera Script -//Linden Lab -//Dan Linden -//Hijacked by Penny Patton to show what SL looks like with better camera placement! -//Search script for "changedefault" to find the line you need to alter to change the default view you see when first attaching the HUD! -// -//parts from: -// Script Vitality - keeps the script itself and all scripts in same prim -// running also in 'dead' areas, those areas where scrpts are not allowed. -// This works simply by taking avatar controls. -// Author Jenna Felton -// Version 1.0 -// -//modified by: Zopf Resident - Ray Zopf (Raz) -//Additions: when reusing some older code -//09. Mrz. 2014 -//v1.1 -// - - +string g_sAuthors = "Zopf"; // Constants list MENU_MAIN = ["Centre","Right","Left","Cam ON","Cam OFF"]; @@ -597,6 +64,9 @@ list MENU_2 = ["More...","...Back"]; //SCRIPT MESSAGE MAP integer CH; +// Variables +key g_kOwner; + integer g_iHandle = 0; integer g_iOn = 0; integer trap = 0; @@ -608,90 +78,44 @@ integer trap = 0; //=============================================== //PREDEFINED FUNCTIONS //=============================================== -/* -//XXX -//NG lets send pings here and listen for pong replys -SendCommand(key id) -{ - if (llGetListLength(LISTENERS) >= 60) return; // lets not cause "too many listen" error - - integer channel = getPersonalChannel(id, 1111); - llRegionSayTo(id, channel, (string)id+ ":ping"); - LISTENERS += [ llListen(channel, "", NULL_KEY, "" )] ;// if we have a reply on the channel lets see what it is. - llSetTimerEvent(5.0);// no reply by now, lets kick off the timer -} -*/ - -//most important function -//----------------------------------------------- -take_camera_control(key id){ - llOwnerSay("take_camera_control"); - llOwnerSay(((string)id)); - llRequestPermissions(id,2048); - llSetCameraParams([12,1]); - (g_iOn = 1); -} - -release_camera_control(key id){ - llOwnerSay("release_camera_control"); - llSetCameraParams([12,0]); - llReleaseCamera(id); - (g_iOn = 0); -} - - -focus_on_me(){ - llOwnerSay("focus_on_me"); - vector here = llGetPos(); - llSetCameraParams([12,1,8,0.0,9,0.0,7,0.0,17,here,6,0.0,22,1,11,0.0,13,(here + <4.0,4.0,4.0>),5,0.0,21,1,10,0.0,1,ZERO_VECTOR]); +initExtension(integer conf){ + llListenRemove(1); + llListenRemove(g_iHandle); + (CH = (-50000 - llRound((llFrand(1) * 100000)))); + (g_iHandle = llListen(CH,"",g_kOwner,"")); + if (conf) llRequestPermissions(g_kOwner,2048); + llOwnerSay(((((g_sTitle + " (") + g_sVersion) + ") Enhancements by ") + g_sAuthors)); + if (verbose) { + + llOwnerSay(((((((((("\n\t-used/max available memory: " + ((string)llGetUsedMemory())) + "/") + ((string)llGetMemoryLimit())) + " - free: ") + ((string)llGetFreeMemory())) + "-\n(v) ") + g_sTitle) + "/") + g_sScriptName)); + } } -default_cam(){ +defCam(){ llClearCameraParams(); llSetCameraParams([12,1]); } -shoulder_cam2(){ - llOwnerSay("Right Shoulder"); - default_cam(); - llSetCameraParams([12,1,8,0.0,9,0.0,7,0.5,6,1.0e-2,22,0,11,0.0,0,15.0,5,0.1,21,0,10,0.0,1,<-0.5,-0.5,0.75>]); -} - - -shoulder_cam(){ - llOwnerSay("shoulder_cam"); - default_cam(); +shoulderCam(){ + llOwnerSay("shoulderCam"); + defCam(); llSetCameraParams([12,1,8,5.0,9,0.0,7,0.5,6,1.0e-2,22,0,11,0.0,0,15.0,5,0.1,21,0,10,0.0,1,<-0.5,-0.5,0.75>]); } -shoulder_cam3(){ - llOwnerSay("Left Shoulder"); - default_cam(); - llSetCameraParams([12,1,8,5.0,9,0.0,7,0.5,6,1.0e-2,22,0,11,0.0,0,15.0,5,0.1,21,0,10,0.0,1,<-0.5,0.5,0.75>]); -} - - -centre_cam(){ - llOwnerSay("centre_cam"); - default_cam(); - llSetCameraParams([12,1,8,0.0,9,0.0,7,0.5,6,1.0e-2,22,0,11,0.0,0,15.0,5,0.1,21,0,10,0.0,1,<-0.5,0.0,0.75>]); -} - - drop_camera_5_seconds(){ llOwnerSay("drop_camera_5_seconds"); llSetCameraParams([12,1,8,0.0,9,0.5,7,3.0,6,2.0,22,0,11,0.0,0,0.0,5,5.0e-2,21,1,10,0.0,1,<0.0,0.0,0.0>]); llSleep(5); - default_cam(); + defCam(); } -worm_cam(){ - llOwnerSay("worm_cam"); +wormCam(){ + llOwnerSay("wormCam"); llSetCameraParams([12,1,8,180.0,9,0.0,7,8.0,6,0.0,22,0,11,4.0,0,-45.0,5,1.0,21,0,10,1.0,1,<0.0,0.0,0.0>]); } @@ -704,15 +128,7 @@ spin_cam(){ (camera_position = (llGetPos() + (<0.0,4.0,0.0> * llEuler2Rot(<0.0,0.0,i>)))); llSetCameraParams([13,camera_position]); } - default_cam(); -} - - -setup_listen(){ - llListenRemove(1); - llListenRemove(g_iHandle); - (CH = (-50000 - llRound((llFrand(1) * 100000)))); - (g_iHandle = llListen(CH,"","","")); + defCam(); } @@ -728,49 +144,6 @@ setup_listen(){ default { /* -//XXX - state_entry() - { - //debug=TRUE; // set to TRUE to enable Debug messages - - g_kOwner = llGetOwner(); - g_sScriptName = llGetScriptName(); - - if (debug) Debug((string)llGetFreeMemory() + " bytes free", FALSE, FALSE); - llWhisper(0, g_sTitle +" ("+ g_sVersion +") Enhancements by "+g_sAuthors); - llWhisper(0, "INSTRUCTIONS"); - if (verbose) llWhisper(0, "Loading notecard..."); - ; - //listener=llListen(getPersonalChannel(wearer,1111),"","",""); //lets listen here - } - -//XXX - timer()//clear things after ping - { - llSetTimerEvent(0); - AGENTS = []; - integer n = llGetListLength(LISTENERS) - 1; - for (; n >= 0; n--) - { - llListenRemove(llList2Integer(LISTENERS,n)); - } - LISTENERS = []; - } - -//XXX - on_rez(integer i) - { - ; - } - -//XXX - changed(integer change) - { - if(change & CHANGED_INVENTORY) ; - if(change & CHANGED_REGION) ; - if(change & CHANGED_OWNER) llResetScript(); - } - //XXX //let it run in noscript areas //----------------------------------------------- @@ -800,9 +173,16 @@ default { */ state_entry() { - llSitTarget(<0.0,0.0,0.1>,ZERO_ROTATION); - setup_listen(); - llSetTimerEvent(2.0); + (g_kOwner = llGetOwner()); + (g_sScriptName = llGetScriptName()); + (verbose = 0); + integer rc = 0; + (rc = llSetMemoryLimit(24000)); + if (verbose) if ((!rc)) { + llOwnerSay((((("(v) " + g_sTitle) + "/") + g_sScriptName) + " - could not set memory limit")); + } + + initExtension(0); } @@ -826,28 +206,39 @@ default { if ((message == "More...")) llDialog(id,"Pick an option!",MENU_2,CH); else if ((message == "...Back")) llDialog(id,"What do you want to do?",MENU_MAIN,CH); else if ((message == "Cam ON")) { - take_camera_control(id); + llOwnerSay(("takeCamCtrl\n" + ((string)id))); + llRequestPermissions(id,2048); + llSetCameraParams([12,1]); + (g_iOn = 1); } else if ((message == "Cam OFF")) { - release_camera_control(id); + llOwnerSay("releaseCamCtrl"); + llClearCameraParams(); + (g_iOn = 0); } else if ((message == "Default")) { - default_cam(); + defCam(); } else if ((message == "Right")) { - shoulder_cam2(); + llOwnerSay("Right Shoulder"); + defCam(); + llSetCameraParams([12,1,8,0.0,9,0.0,7,0.5,6,1.0e-2,22,0,11,0.0,0,15.0,5,0.1,21,0,10,0.0,1,<-0.5,-0.5,0.75>]); } else if ((message == "Worm Cam")) { - worm_cam(); + wormCam(); } else if ((message == "Centre")) { - centre_cam(); + llOwnerSay("centreCam"); + defCam(); + llSetCameraParams([12,1,8,0.0,9,0.0,7,0.5,6,1.0e-2,22,0,11,0.0,0,15.0,5,0.1,21,0,10,0.0,1,<-0.5,0.0,0.75>]); } else if ((message == "Left")) { - shoulder_cam3(); + llOwnerSay("Left Shoulder"); + defCam(); + llSetCameraParams([12,1,8,5.0,9,0.0,7,0.5,6,1.0e-2,22,0,11,0.0,0,15.0,5,0.1,21,0,10,0.0,1,<-0.5,0.5,0.75>]); } else if ((message == "Shoulder")) { - shoulder_cam(); + shoulderCam(); } else if ((message == "Drop Cam")) { drop_camera_5_seconds(); @@ -883,28 +274,21 @@ default { if ((change & 32)) { key id = llAvatarOnSitTarget(); if (id) { - setup_listen(); - llRequestPermissions(id,2048); + initExtension(1); } } + if ((change & 128)) llResetScript(); } attach(key id) { - if (id) { - setup_listen(); - llRequestPermissions(id,2048); - shoulder_cam(); - } - } - - - - timer() { - if ((trap == 1)) { - focus_on_me(); + if ((id == g_kOwner)) { + initExtension(1); + llOwnerSay("Right Shoulder"); + defCam(); + llSetCameraParams([12,1,8,0.0,9,0.0,7,0.5,6,1.0e-2,22,0,11,0.0,0,15.0,5,0.1,21,0,10,0.0,1,<-0.5,-0.5,0.75>]); } + else llResetScript(); } } ->>>>>>> refs/tags/release_fix-listen diff --git a/LSL/CameraScript.lslp b/LSL/CameraScript.lslp index 3a2f07c..0adb431 100644 --- a/LSL/CameraScript.lslp +++ b/LSL/CameraScript.lslp @@ -17,8 +17,8 @@ // //modified by: Zopf Resident - Ray Zopf (Raz) //Additions: when reusing some older code -//09. Mrz. 2014 -//v1.1 +//10. Mrz. 2014 +//v1.21 // //Files: @@ -46,13 +46,13 @@ //user changeable variables //----------------------------------------------- -integer verbose = TRUE; // show more/less info during startup +integer verbose; // show more/less info during startup //internal variables //----------------------------------------------- -string g_sTitle = "CameraScript"; // title -string g_sVersion = "1.1"; // version +string g_sTitle = "CameraScript"; // title +string g_sVersion = "1.21"; // version string g_sScriptName; string g_sAuthors = "Zopf"; @@ -76,9 +76,6 @@ integer spaz = 0; integer trap = 0; -list LISTENERS; // list of hud channel handles we are listening for, for building lists - - //=============================================== //LSLForge MODULES //=============================================== @@ -86,7 +83,7 @@ list LISTENERS; // list of hud channel handles we are listening for, for buildin //general modules //----------------------------------------------- $import Debug2.lslm(m_sScriptName=g_sScriptName); -$import MemoryManagement.lslm(m_sTitle=g_sTitle, m_sScriptName=g_sScriptName, m_iVerbose=verbose); +$import MemoryManagement2.lslm(m_sTitle=g_sTitle, m_sScriptName=g_sScriptName, m_iVerbose=verbose); //project specific modules //----------------------------------------------- @@ -95,37 +92,33 @@ $import MemoryManagement.lslm(m_sTitle=g_sTitle, m_sScriptName=g_sScriptName, m_ //=============================================== //PREDEFINED FUNCTIONS //=============================================== -/* -//XXX -//NG lets send pings here and listen for pong replys -SendCommand(key id) -{ - if (llGetListLength(LISTENERS) >= 60) return; // lets not cause "too many listen" error - integer channel = getPersonalChannel(id, 1111); - llRegionSayTo(id, channel, (string)id+ ":ping"); - LISTENERS += [ llListen(channel, "", NULL_KEY, "" )] ;// if we have a reply on the channel lets see what it is. - llSetTimerEvent(5.0);// no reply by now, lets kick off the timer +initExtension(integer conf) +{ + setupListen(); + if (conf) llRequestPermissions(g_kOwner, PERMISSION_CONTROL_CAMERA); + llOwnerSay(g_sTitle +" ("+ g_sVersion +") Enhancements by "+g_sAuthors); + if (verbose) MemInfo(FALSE); } -*/ + +// pragma inline //most important function //----------------------------------------------- -take_camera_control(key id) +takeCamCtrl(key id) { - llOwnerSay("take_camera_control"); // say function name for debugging - llOwnerSay( (string)id); + llOwnerSay("takeCamCtrl\n"+(string)id); // say function name for debugging llRequestPermissions(id, PERMISSION_CONTROL_CAMERA); llSetCameraParams([CAMERA_ACTIVE, 1]); // 1 is active, 0 is inactive g_iOn = TRUE; } -release_camera_control(key id) +// pragma inline +releaseCamCtrl(key id) { - llOwnerSay("release_camera_control"); // say function name for debugging - llSetCameraParams([CAMERA_ACTIVE, 0]); // 1 is active, 0 is inactive - llReleaseCamera(id); + llOwnerSay("releaseCamCtrl"); // say function name for debugging + llClearCameraParams(); g_iOn = FALSE; } @@ -154,18 +147,19 @@ focus_on_me() } -default_cam() +defCam() { -// llOwnerSay("default_cam"); // say function name for debugging -llClearCameraParams(); // reset camera to default +// llOwnerSay("defCam"); // say function name for debugging + llClearCameraParams(); // reset camera to default llSetCameraParams([CAMERA_ACTIVE, 1]); } -shoulder_cam2() +// pragma inline +shoulderCamRight() { llOwnerSay("Right Shoulder"); // say function name for debugging - default_cam(); + defCam(); llSetCameraParams([ CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive CAMERA_BEHINDNESS_ANGLE, 0.0, // (0 to 180) degrees @@ -185,10 +179,10 @@ shoulder_cam2() } -shoulder_cam() +shoulderCam() { - llOwnerSay("shoulder_cam"); // say function name for debugging - default_cam(); + llOwnerSay("shoulderCam"); // say function name for debugging + defCam(); llSetCameraParams([ CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive CAMERA_BEHINDNESS_ANGLE, 5.0, // (0 to 180) degrees @@ -208,10 +202,11 @@ shoulder_cam() } -shoulder_cam3() +// pragma inline +shoulderCamLeft() { llOwnerSay("Left Shoulder"); // say function name for debugging - default_cam(); + defCam(); llSetCameraParams([ CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive CAMERA_BEHINDNESS_ANGLE, 5.0, // (0 to 180) degrees @@ -230,11 +225,11 @@ shoulder_cam3() ]); } - -centre_cam() +// pragma inline +centreCam() { - llOwnerSay("centre_cam"); // say function name for debugging - default_cam(); + llOwnerSay("centreCam"); // say function name for debugging + defCam(); llSetCameraParams([ CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive CAMERA_BEHINDNESS_ANGLE, 0.0, // (0 to 180) degrees @@ -274,13 +269,13 @@ drop_camera_5_seconds() CAMERA_FOCUS_OFFSET, <0.0,0.0,0.0> // <-10,-10,-10> to <10,10,10> meters ]); llSleep(5); - default_cam(); + defCam(); } -worm_cam() +wormCam() { - llOwnerSay("worm_cam"); // say function name for debugging + llOwnerSay("wormCam"); // say function name for debugging llSetCameraParams([ CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive CAMERA_BEHINDNESS_ANGLE, 180.0, // (0 to 180) degrees @@ -327,7 +322,7 @@ spaz_cam() ]); llSleep(0.1); } - default_cam(); + defCam(); } @@ -357,16 +352,16 @@ spin_cam() camera_position = llGetPos() + <0.0, 4.0, 0.0> * llEuler2Rot(<0.0, 0.0, i>); llSetCameraParams([CAMERA_POSITION, camera_position]); } - default_cam(); + defCam(); } - -setup_listen() + // pragma inline +setupListen() { llListenRemove(1); llListenRemove(g_iHandle); CH = -50000 -llRound(llFrand(1) * 100000); - g_iHandle = llListen(CH, "", "", ""); // listen for dialog answers + g_iHandle = llListen(CH, "", g_kOwner, ""); // listen for dialog answers } @@ -382,49 +377,6 @@ setup_listen() default { /* -//XXX - state_entry() - { - //debug=TRUE; // set to TRUE to enable Debug messages - - g_kOwner = llGetOwner(); - g_sScriptName = llGetScriptName(); - - if (debug) Debug((string)llGetFreeMemory() + " bytes free", FALSE, FALSE); - llWhisper(0, g_sTitle +" ("+ g_sVersion +") Enhancements by "+g_sAuthors); - llWhisper(0, "INSTRUCTIONS"); - if (verbose) llWhisper(0, "Loading notecard..."); - ; - //listener=llListen(getPersonalChannel(wearer,1111),"","",""); //lets listen here - } - -//XXX - timer()//clear things after ping - { - llSetTimerEvent(0); - AGENTS = []; - integer n = llGetListLength(LISTENERS) - 1; - for (; n >= 0; n--) - { - llListenRemove(llList2Integer(LISTENERS,n)); - } - LISTENERS = []; - } - -//XXX - on_rez(integer i) - { - ; - } - -//XXX - changed(integer change) - { - if(change & CHANGED_INVENTORY) ; - if(change & CHANGED_REGION) ; - if(change & CHANGED_OWNER) llResetScript(); - } - //XXX //let it run in noscript areas //----------------------------------------------- @@ -455,9 +407,15 @@ default state_entry() { - llSitTarget(<0.0, 0.0, 0.1>, ZERO_ROTATION); - setup_listen(); - llSetTimerEvent(2.0); + //debug=TRUE; // set to TRUE to enable Debug messages + g_kOwner = llGetOwner(); + g_sScriptName = llGetScriptName(); + verbose = FALSE; + + MemRestrict(24000, FALSE); + if (debug) Debug("state_entry", TRUE, TRUE); + + initExtension(FALSE); } @@ -478,34 +436,32 @@ default listen(integer channel, string name, key id, string message) { if (~llListFindList(MENU_MAIN + MENU_2, [message])) // verify dialog choice -// if (~llListFindList(MENU_MAIN, [message])) // verify dialog choice { -// llOwnerSay(name + " picked the option '" + message + "'."); // output the answer if (message == "More...") llDialog(id, "Pick an option!", MENU_2, CH); // present submenu on request else if (message == "...Back") llDialog(id, "What do you want to do?", MENU_MAIN, CH); // present main menu on request to go back else if (message == "Cam ON") { - take_camera_control(id); + takeCamCtrl(id); } else if (message == "Cam OFF") { - release_camera_control(id); + releaseCamCtrl(id); } else if (message == "Default") { - default_cam(); + defCam(); } else if (message == "Right") { - shoulder_cam2(); + shoulderCamRight(); } else if (message == "Worm Cam") { - worm_cam(); + wormCam(); } else if (message == "Centre") { - centre_cam(); + centreCam(); } else if (message == "Left") { - shoulder_cam3(); + shoulderCamLeft(); } else if (message == "Shoulder") { - shoulder_cam(); + shoulderCam(); } else if (message == "Drop Cam") { drop_camera_5_seconds(); @@ -524,7 +480,8 @@ default } - run_time_permissions(integer perm) { + run_time_permissions(integer perm) + { if (perm & PERMISSION_CONTROL_CAMERA) { llSetCameraParams([CAMERA_ACTIVE, 1]); // 1 is active, 0 is inactive llOwnerSay("Camera permissions have been taken"); @@ -537,29 +494,20 @@ default if (change & CHANGED_LINK) { key id = llAvatarOnSitTarget(); if (id) { - setup_listen(); - llRequestPermissions(id, PERMISSION_CONTROL_CAMERA); + initExtension(TRUE); } } + if (change & CHANGED_OWNER) llResetScript(); } attach(key id) { - if (id) { - setup_listen(); - llRequestPermissions(id, PERMISSION_CONTROL_CAMERA); - shoulder_cam(); - //changedefault The above is what you need to change to change the default camera view you see whenever you first attach the HUD. For example, change it to centre_cam(); to have the default view be centered behind your avatar! - } - } - - - timer() - { - if (trap == 1) { - focus_on_me(); - } + if (id == g_kOwner) { + initExtension(TRUE); + shoulderCamRight(); + //changedefault The above is what you need to change to change the default camera view you see whenever you first attach the HUD. For example, change it to centreCam(); to have the default view be centered behind your avatar! + } else llResetScript(); } //-----------------------------------------------