diff --git a/MOAP Top 2000 Radio Stations Player/Top_Radio_Stations_Player/Object/Top_Radio_Stations_Player_1.lsl b/MOAP Top 2000 Radio Stations Player/Top_Radio_Stations_Player/Object/Top_Radio_Stations_Player_1.lsl index a929236d..3806aa6e 100644 --- a/MOAP Top 2000 Radio Stations Player/Top_Radio_Stations_Player/Object/Top_Radio_Stations_Player_1.lsl +++ b/MOAP Top 2000 Radio Stations Player/Top_Radio_Stations_Player/Object/Top_Radio_Stations_Player_1.lsl @@ -4,7 +4,7 @@ // :AUTHOR:Ferd Frederix // :KEYWORDS: // :CREATED:2012-09-04 15:30:52.010 -// :EDITED:2016-06-27 20:52:33 +// :EDITED:2016-07-09 14:33:55 // :ID:902 // :NUM:1278 // :REV:1.1 diff --git a/NPC_Cat_Follower/NPC_Cat_Follower/Cat Bowl/NPC_Follower_Cat.lsl b/NPC_Cat_Follower/NPC_Cat_Follower/Cat Bowl/NPC_Follower_Cat.lsl index 98566cb3..798cebee 100644 --- a/NPC_Cat_Follower/NPC_Cat_Follower/Cat Bowl/NPC_Follower_Cat.lsl +++ b/NPC_Cat_Follower/NPC_Cat_Follower/Cat Bowl/NPC_Follower_Cat.lsl @@ -1,50 +1,80 @@ -// :SHOW: +// :SHOW:1 // :CATEGORY:OpenSim NPC // :NAME:NPC_Cat_Follower // :AUTHOR:Ferd Frederix // :KEYWORDS: // :CREATED:2013-11-27 13:33:04 -// :EDITED:2015-05-29 11:26:02 +// :EDITED:2016-07-09 14:33:57 // :ID:1004 // :NUM:785 -// :REV:1.1 +// :REV:2.0 // :WORLD:OpenSim // :DESCRIPTION: // A NPC follower. Will follow close to any avatar. // Touch to turn on or off. // Has lots of mods by Ferd Frederix // License: http://creativecommons.org/licenses/by-nc -// original author: jpvdgiessen +// some code bits from author: jpvdgiessen // You are free: // to Share — to copy, distribute and transmit the work // to Remix — to adapt the work // :CODE: +// Rev 2 - remove timers. // tunables -float max_distance = 96; //distance for sensoring a real avatar -string fName = "Orana"; -string lName = "Kitty"; +integer debug = FALSE; +string fName = "Orana"; +string lName = "Kthxbye"; + +float MIN = 5; +float MAX = 10; // how long the cat waits or sits, is beteween these two values +float TimerTick = 1; // keep this around a second +float TIME = 5; // how often to look for avatar (keep this slow) +float max_distance = 35; //distance for sensoring a real avatar +float near_distance= 3; // how close the cat stays around +float claw_distance= 1 ;// will claw you hen this close + // stuff -integer iWaitCounter = 60; +integer iWaitCounter = 60; // if we cannot get there in time, integer channel; // dialog channel integer listener; // holds the listener handle; key npc; // npc key integer npc_on = FALSE; vector Dest; string lastAnim; - +float gTimer; + +DEBUG(string str) +{ + if (debug) llOwnerSay(str); +} + +Remove() +{ + lastAnim = ""; + npc_on = TRUE; + osNpcRemove(llGetObjectDesc()); +} + Play(string anima) { - if (anima == lastAnim) + if (anima == lastAnim) { + DEBUG("Same"); return; + } + // 1/5 the time, ionstead of standing, we lay down if (anima == "Stand" && llFrand(5) < 1) { anima = "Sit1"; } + gTimer =randBetween(MIN,MAX); + llSensorRepeat("", NULL_KEY, AGENT_BY_LEGACY_NAME, max_distance, PI, gTimer); + DEBUG(anima + " time = " + (string) gTimer); + osNpcPlayAnimation(npc,anima); osNpcStopAnimation(npc,lastAnim); lastAnim = anima; @@ -65,53 +95,54 @@ Sound() walk_to_master(vector myPos) { - vector myVector = ; + DEBUG( "walk to " + (string) Dest); + vector myVector = ; myPos.z = 0; iWaitCounter = 60; Play("Walk"); osNpcMoveToTarget(npc, myPos + myVector, OS_NPC_NO_FLY ); - llSetTimerEvent(0.5); - Sound(); + llSetTimerEvent(TimerTick); + if (llFrand(5) < .5) + Sound(); } float randBetween(float min, float max) { return llFrand(max - min) + min ; } -dialog() +dialog(key avi) { channel = llCeil(llFrand(5000) + 5000); listener = llListen(channel,"","",""); - llDialog(llGetOwner(), "Choose:",["Start","Remove","Appearance"],channel); + llDialog(avi, "Choose:",["Start","Remove","Appearance"],channel); } + Start() { - vector npcPos = llGetPos() + <1.0,1.0,1.0>; + Remove(); + vector npcPos = llGetPos() + <0.0,0.0,1.0>; npc = osNpcCreate(fName,lName, npcPos, "Appearance"); llSetObjectDesc(npc); npc_on = TRUE; - llSensor("", NULL_KEY, AGENT_BY_LEGACY_NAME, max_distance, PI); + osSetSpeed(npc,0.8); + llSensorRepeat("", NULL_KEY, AGENT_BY_LEGACY_NAME, max_distance, PI, TIME); + llSetTimerEvent(TimerTick); } default { - state_entry() { - llSay(0,"Ready"); - osNpcRemove(llGetObjectDesc()); - dialog(); + llSay(0,"starting"); + Start(); } changed (integer what) { if (what & CHANGED_REGION_START) { - if (npc_on) - { - Start(); - } + Start(); } } @@ -122,8 +153,8 @@ default touch_start(integer x) { - if (llDetectedKey(0) == llGetOwner()) { - dialog(); + if (llDetectedKey(0) == llGetOwner() || llSameGroup(llDetectedKey(0))) { + dialog(llDetectedKey(0)); } } @@ -131,18 +162,16 @@ default llListenRemove (listener); if (msg == "Start") { - if( !npc_on ) { - Start(); - } else { - llOwnerSay("Already running"); - } + Start(); } else if (msg == "Remove") { npc_on = FALSE; - osNpcRemove(llGetObjectDesc()); + Remove(); + llSensorRemove(); llSetTimerEvent(0); - } else if (msg == "Appearance") { + } else if (msg == "-") { osAgentSaveAppearance(llGetOwner(), "Appearance"); llOwnerSay("Your appearance has been saved"); + Start(); } } @@ -152,218 +181,39 @@ default Dest = llDetectedPos( 0 ); walk_to_master(Dest); } + no_sensor() { - Play("Stand"); - llSleep(10); - llSensor("", NULL_KEY, AGENT_BY_LEGACY_NAME, max_distance, PI); + Play("Sit1"); + llSensorRepeat("", NULL_KEY, AGENT_BY_LEGACY_NAME, max_distance, PI, TIME); + llSetTimerEvent(0); } timer() { - vector pos; - if (--iWaitCounter) { - - list Poses = llGetObjectDetails(npc,[OBJECT_POS]); - pos = llList2Vector(Poses, 0); - - if (llVecDist(pos, Dest ) > 4) { - return; - } + // for safety + if (--iWaitCounter == 0) { + DEBUG("Lost cat, rerezzing"); + Start(); + return; } - if (llFrand(5) < 0.5) { - if (llVecDist(pos, Dest ) <1) { - Play("Claw"); - llTriggerSound("kitten4",1.0); - llSleep(1.5); - } else { - Play("Meow"); - llTriggerSound("kitten3",1.0); - llSleep(1.5); - } - - - } + // get NPC position + list P = llGetObjectDetails(npc,[OBJECT_POS]); + vector Npcpos; + Npcpos = llList2Vector(P, 0); - Play("Stand"); + if (llVecDist(Npcpos, Dest ) > 1) { + Play("Stand"); + return; + } - llSleep(llFrand(5) + 1); - llSetTimerEvent(0); - llSensor("", NULL_KEY, AGENT_BY_LEGACY_NAME, max_distance, PI); - - } -} -// tunables -float max_distance = 96; //distance for sensoring a real avatar -string fName = "Orana"; -string lName = "Kitty"; - -// stuff -integer iWaitCounter = 60; -integer channel; // dialog channel -integer listener; // holds the listener handle; -key npc; // npc key -integer npc_on = FALSE; -vector Dest; -string lastAnim; - -Play(string anima) -{ - if (anima == lastAnim) - return; - - if (anima == "Stand" && llFrand(5) < 1) - { - anima = "Sit1"; - } - - osNpcPlayAnimation(npc,anima); - osNpcStopAnimation(npc,lastAnim); - lastAnim = anima; -} - -Sound() -{ - if (llFrand(2) > 0.5) - return; - - integer n = llGetInventoryNumber(INVENTORY_SOUND); - integer n2 = llCeil(llFrand(n)); - - string name = llGetInventoryName(INVENTORY_SOUND,n2); - llTriggerSound(name,1.0); -} - - -walk_to_master(vector myPos) -{ - vector myVector = ; - myPos.z = 0; - - iWaitCounter = 60; - Play("Walk"); - osNpcMoveToTarget(npc, myPos + myVector, OS_NPC_NO_FLY ); - llSetTimerEvent(0.5); - Sound(); -} - -float randBetween(float min, float max) -{ - return llFrand(max - min) + min ; -} -dialog() -{ - channel = llCeil(llFrand(5000) + 5000); - listener = llListen(channel,"","",""); - llDialog(llGetOwner(), "Choose:",["Start","Remove","Appearance"],channel); -} -Start() -{ - vector npcPos = llGetPos() + <1.0,1.0,1.0>; - npc = osNpcCreate(fName,lName, npcPos, "Appearance"); - llSetObjectDesc(npc); - npc_on = TRUE; - llSensor("", NULL_KEY, AGENT_BY_LEGACY_NAME, max_distance, PI); -} - -default -{ - - state_entry() - { - llSay(0,"Ready"); - osNpcRemove(llGetObjectDesc()); - dialog(); - } - - changed (integer what) - { - if (what & CHANGED_REGION_START) + if (llVecDist(Npcpos, Dest ) < claw_distance) { - if (npc_on) - { - Start(); - } - } - } - - on_rez(integer p) - { - llResetScript(); - } - - touch_start(integer x) - { - if (llDetectedKey(0) == llGetOwner()) { - dialog(); - } - } - - listen(integer channel, string name, key id, string msg) { - llListenRemove (listener); - if (msg == "Start") - { - if( !npc_on ) { - Start(); - } else { - llOwnerSay("Already running"); - } - } else if (msg == "Remove") { - npc_on = FALSE; - osNpcRemove(llGetObjectDesc()); - llSetTimerEvent(0); - } else if (msg == "Appearance") { - osAgentSaveAppearance(llGetOwner(), "Appearance"); - llOwnerSay("Your appearance has been saved"); - } - - } - - sensor(integer num) - { - Dest = llDetectedPos( 0 ); - walk_to_master(Dest); - } - no_sensor() - { - Play("Stand"); - llSleep(10); - llSensor("", NULL_KEY, AGENT_BY_LEGACY_NAME, max_distance, PI); - } - - timer() - { - vector pos; - if (--iWaitCounter) { - - list Poses = llGetObjectDetails(npc,[OBJECT_POS]); - pos = llList2Vector(Poses, 0); - - if (llVecDist(pos, Dest ) > 4) { - return; - } - } - - if (llFrand(5) < 0.5) { - if (llVecDist(pos, Dest ) <1) { - Play("Claw"); - llTriggerSound("kitten4",1.0); - llSleep(1.5); - } else { - Play("Meow"); - llTriggerSound("kitten3",1.0); - llSleep(1.5); - } - - - } - - Play("Stand"); - - llSleep(llFrand(5) + 1); - llSetTimerEvent(0); - llSensor("", NULL_KEY, AGENT_BY_LEGACY_NAME, max_distance, PI); - + Play("Claw"); + llTriggerSound("kitten4",1.0); + } else { + Play("Stand"); + } } } diff --git a/Top2000_Radio_Stations_Player/Top_Radio_Stations_Player/Object/Remote parcel script.lsl b/Top2000_Radio_Stations_Player/Top_Radio_Stations_Player/Object/Remote parcel script.lsl index 64951084..590af860 100644 --- a/Top2000_Radio_Stations_Player/Top_Radio_Stations_Player/Object/Remote parcel script.lsl +++ b/Top2000_Radio_Stations_Player/Top_Radio_Stations_Player/Object/Remote parcel script.lsl @@ -4,7 +4,7 @@ // :AUTHOR:Ferd Frederix // :KEYWORDS: // :CREATED:2013-12-14 13:33:32 -// :EDITED:2016-06-27 20:52:41 +// :EDITED:2016-07-09 14:34:03 // :ID:902 // :NUM:1558 // :REV:1.2