Jump to content

testgenord1

Resident
  • Content Count

    21
  • Joined

  • Last visited

Community Reputation

0 Neutral

About testgenord1

  • Rank
    Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hi again. Yes, this is where I got the script from. Sorry about the messy script. So, thank you all very much for taking your time and your patience. Thanks to your help I got the scripts to work. At the top I added the global variable list KFMcommand; I hope this was correct. At least it worked after that. For other users possibly interested in this, I'm adding my final version below. There is probably still room for improvement, so feel free to comment if you like. Here is the new version of the script of the moving part: (The other one I basically left as it was.) // KFM Vocabulary Memory Game Reciever v0.2 by djphil (CC-BY-NC-SA 4.0) and Qie Niangao //https://community.secondlife.com/forums/topic/434279-llsetkeyframedmotion-forward-and-back/ list KFMcommand;//changed original script here. integer canal = -123654789; integer tempo = 5; integer echo; integer count; integer power; string lang; string word; string trad; string prim; vector pos; rotation rot; rotation NormRot(rotation Q) { float MagQ = llSqrt(Q.x*Q.x + Q.y*Q.y +Q.z*Q.z + Q.s*Q.s); return <Q.x/MagQ, Q.y/MagQ, Q.z/MagQ, Q.s/MagQ>; } default { state_entry() { list buffer = llCSV2List(llGetObjectName()); if (llGetListLength(buffer) == 2) { lang = llStringTrim(llList2String(buffer, 0), STRING_TRIM); prim = llStringTrim(llList2String(buffer, 1), STRING_TRIM); } else { llOwnerSay("Error: Bad prim name detected"); return; } buffer = llCSV2List(llGetObjectDesc()); if (llGetListLength(buffer) == 2) { word = llStringTrim(llList2String(buffer, 0), STRING_TRIM); trad = llStringTrim(llList2String(buffer, 1), STRING_TRIM); } else { llOwnerSay("Error: Bad prim desc detected"); return; } llSetText("state: ready", <1.0, 1.0, 1.0>, 1.0); llSetLinkPrimitiveParamsFast(LINK_THIS, [ PRIM_PHYSICS_SHAPE_TYPE, PRIM_PHYSICS_SHAPE_CONVEX ]); } touch_start(integer number) { llListenRemove(echo); count = 0; if (power =! power) { echo = llListen(canal, prim + "," + lang, NULL_KEY, ""); llSetTimerEvent(0.1); } else { llSetTimerEvent(0.0); } llSetText("state: ready", <1.0, 1.0, 1.0>, 1.0); } listen(integer channel, string name, key id, string message) { list buffer = llCSV2List(name); if (llGetListLength(buffer) == 2) { name = llList2String(buffer, 0); if (name == prim) { buffer = llCSV2List(message); if (llGetListLength(buffer) == 3) { message = llList2String(buffer, 0); pos = (vector)llList2String(buffer, 1);//changed original script here. rot = llList2Rot(buffer, 1); if (message == trad) { llListenRemove(echo); power =! power; llShout(canal, message); state move; } } } } } timer() { llSetTimerEvent(1.0); llShout(canal, word + "," + (string)llGetPos() + "," + (string)llGetRot()); if (count > tempo) { llResetScript(); } llSetText("time left: " + (tempo - count), <1.0, 1.0, 1.0>, 1.0); ++count; } } state move//changed original script here. { state_entry() { llOwnerSay(llGetScriptName()+" in move state with pos = "+(string)pos); rotation spin = NormRot(llEuler2Rot(<90.0, 0.0, 0.0> * DEG_TO_RAD)); KFMcommand = [ <0.0, 0.0, 1.0> * llGetRot(), ZERO_ROTATION, 0.5, pos - llGetPos(), ZERO_ROTATION, 1.0, ZERO_VECTOR, spin, 0.5 ]; llSetKeyframedMotion(KFMcommand, [KFM_MODE, KFM_FORWARD]); llSleep(5); } touch_end(integer num_detected) { llShout(canal, word + "," + (string)llGetPos() + "," + (string)llGetRot()); llSetKeyframedMotion(KFMcommand, [KFM_MODE, KFM_REVERSE]); llShout(canal, trad); //llSetText("lang: " + lang + "\nword: " + word + "\ntrad: " + trad, <1.0, 1.0, 1.0>, 1.0); llResetScript(); } }
  2. Thank you for your reply. The scripts do work. I forgot to mention that you have to give a particular name and description to both prims. For example: prim 1: name: English,German description: Vocabulary,Vokabular prim 2: name: German,English description: Vokabular,Vocabulary
  3. Hi! I've got a script that makes a prim move on top of a different prim when clicked on, and then automatically move back to its initial position. I would like the prim to remain on top of that prim and only move back when clicked on a second time. The movement has to be split into two parts (the back-movement part seems to go into the timer below), and then a touch_start event has to be built into it, but I haven't been able to achieve this. Maybe you have some ideas? Here is the part of the script containing the movement: state move { state_entry() { rotation spin = NormRot(llEuler2Rot(<0.0, 0.0, 180.0> * DEG_TO_RAD)); llSetTimerEvent(0.1); llSetKeyframedMotion([ <0.0, 0.0, 1.0> * llGetRot(), ZERO_ROTATION, 0.5, pos - llGetPos() + ZERO_VECTOR * llGetRot(), ZERO_ROTATION, 1.0, ZERO_VECTOR, spin, 0.5, ZERO_VECTOR, ZERO_ROTATION, 1.0, llGetPos() - pos + ZERO_VECTOR * llGetRot(), ZERO_ROTATION, 1.0, -<0.0, 0.0, 1.0> * llGetRot(), ZERO_ROTATION, 0.5, ZERO_VECTOR, spin, 0.5 ], [KFM_MODE, KFM_FORWARD]); } timer() { llSetTimerEvent(1.0); llShout(canal, word + "," + (string)llGetPos() + "," + (string)llGetRot()); if (count > 5) { llShout(canal, trad); llResetScript(); } llSetText("lang: " + lang + "\nword: " + word + "\ntrad: " + trad, <1.0, 1.0, 1.0>, 1.0); ++count; } } Thank you very much in advance. I'm adding the complete 2 scripts for context: 1. The script of the prim doing the movement: // KFM Vocabulary Memory Game Reciever v0.2 by djphil (CC-BY-NC-SA 4.0) integer canal = -123654789; integer tempo = 5; integer echo; integer count; integer power; string lang; string word; string trad; string prim; vector pos; rotation rot; rotation NormRot(rotation Q) { float MagQ = llSqrt(Q.x*Q.x + Q.y*Q.y +Q.z*Q.z + Q.s*Q.s); return <Q.x/MagQ, Q.y/MagQ, Q.z/MagQ, Q.s/MagQ>; } default { state_entry() { list buffer = llCSV2List(llGetObjectName()); if (llGetListLength(buffer) == 2) { lang = llStringTrim(llList2String(buffer, 0), STRING_TRIM); prim = llStringTrim(llList2String(buffer, 1), STRING_TRIM); } else { llOwnerSay("Error: Bad prim name detected"); return; } buffer = llCSV2List(llGetObjectDesc()); if (llGetListLength(buffer) == 2) { word = llStringTrim(llList2String(buffer, 0), STRING_TRIM); trad = llStringTrim(llList2String(buffer, 1), STRING_TRIM); } else { llOwnerSay("Error: Bad prim desc detected"); return; } llSetText("lang: " + lang + "\nword: " + word + "\nstate: ready", <1.0, 1.0, 1.0>, 1.0); llSetLinkPrimitiveParamsFast(LINK_THIS, [ PRIM_PHYSICS_SHAPE_TYPE, PRIM_PHYSICS_SHAPE_CONVEX ]); } touch_start(integer number) { llListenRemove(echo); count = 0; if (power =! power) { echo = llListen(canal, prim + "," + lang, NULL_KEY, ""); llSetTimerEvent(0.1); } else { llSetTimerEvent(0.0); } llSetText("lang: " + lang + "\nword: " + word + "\nstate: ready", <1.0, 1.0, 1.0>, 1.0); } listen(integer channel, string name, key id, string message) { list buffer = llCSV2List(name); if (llGetListLength(buffer) == 2) { name = llList2String(buffer, 0); if (name == prim) { buffer = llCSV2List(message); if (llGetListLength(buffer) == 3) { message = llList2String(buffer, 0); pos = llList2Vector(buffer, 1); rot = llList2Rot(buffer, 1); if (message == trad) { llListenRemove(echo); power =! power; llShout(canal, message); state move; } } } } } timer() { llSetTimerEvent(1.0); llShout(canal, word + "," + (string)llGetPos() + "," + (string)llGetRot()); if (count > tempo) { llResetScript(); } llSetText("lang: " + lang + "\nword: " + word + "\ntimeleft: " + (tempo - count), <1.0, 1.0, 1.0>, 1.0); ++count; } } state move { state_entry() { rotation spin = NormRot(llEuler2Rot(<0.0, 0.0, 180.0> * DEG_TO_RAD)); llSetTimerEvent(0.1); llSetKeyframedMotion([ <0.0, 0.0, 1.0> * llGetRot(), ZERO_ROTATION, 0.5, pos - llGetPos() + ZERO_VECTOR * llGetRot(), ZERO_ROTATION, 1.0, ZERO_VECTOR, spin, 0.5, ZERO_VECTOR, ZERO_ROTATION, 1.0, llGetPos() - pos + ZERO_VECTOR * llGetRot(), ZERO_ROTATION, 1.0, -<0.0, 0.0, 1.0> * llGetRot(), ZERO_ROTATION, 0.5, ZERO_VECTOR, spin, 0.5 ], [KFM_MODE, KFM_FORWARD]); } timer() { llSetTimerEvent(1.0); llShout(canal, word + "," + (string)llGetPos() + "," + (string)llGetRot()); if (count > 5) { llShout(canal, trad); llResetScript(); } llSetText("lang: " + lang + "\nword: " + word + "\ntrad: " + trad, <1.0, 1.0, 1.0>, 1.0); ++count; } } 2. ... and the script of the other prim: // KFM Vocabulary Memory Game Emitter v0.2 by djphil (CC-BY-NC-SA 4.0) integer canal = -123654789; integer tempo = 5; integer echo; integer count; integer power; string lang; string word; string trad; string prim; default { state_entry() { list buffer = llCSV2List(llGetObjectName()); if (llGetListLength(buffer) == 2) { lang = llStringTrim(llList2String(buffer, 0), STRING_TRIM); prim = llStringTrim(llList2String(buffer, 1), STRING_TRIM); } else { llOwnerSay("Error: Bad prim name detected"); return; } buffer = llCSV2List(llGetObjectDesc()); if (llGetListLength(buffer) == 2) { word = llStringTrim(llList2String(buffer, 0), STRING_TRIM); trad = llStringTrim(llList2String(buffer, 1), STRING_TRIM); } else { llOwnerSay("Error: Bad prim desc detected"); return; } llSetText("lang: " + lang + "\nword: " + word + "\nstate: ready", <1.0, 1.0, 1.0>, 1.0); } touch_start(integer number) { llListenRemove(echo); count = 0; if (power =! power) { echo = llListen(canal, prim + "," + lang, NULL_KEY, ""); llSetTimerEvent(0.1); } else { llSetTimerEvent(0.0); } llSetText("lang: " + lang + "\nword: " + word + "\nstate: ready", <1.0, 1.0, 1.0>, 1.0); } listen(integer channel, string name, key id, string message) { list buffer = llCSV2List(name); if (llGetListLength(buffer) == 2) { name = llList2String(buffer, 0); if (name == prim) { if (message == word) { llSetTimerEvent(0.0); state move; } } } } timer() { llSetTimerEvent(1.0); llShout(canal, word + "," +(string)llGetPos() + "," + (string)llGetRot()); if (count > tempo) { llResetScript(); } llSetText("lang: " + lang + "\nword: " + word + "\ntimeleft: " + (tempo - count), <1.0, 1.0, 1.0>, 1.0); ++count; } } state move { state_entry() { llListenRemove(echo); echo = llListen(canal, prim + "," + lang, NULL_KEY, ""); llSetText("lang: " + lang + "\nword: " + word + "\ntrad: " + trad, <1.0, 1.0, 1.0>, 1.0); } listen(integer channel, string name, key id, string message) { list buffer = llCSV2List(name); if (llGetListLength(buffer) == 2) { name = llList2String(buffer, 0); if (name == prim) { if (message == word) { llResetScript(); } } } } }
  4. Thanks for the suggestion! I'll try that.😊
  5. Hi again! Thank you very much for your support! Sorry about the messy script. Your script looks a lot nicer this way Btw. do you know a good editor for lsl scripts that puts them in a nicer format and maybe also helps to debug scripts?. The script isn't originally mine. I kept the lists in place since it is also possible to shoot at the zombie with a gun and kill it this way. I just don't want to use this in school. Maybe somebody else has some use for this. I just kept he lookat values the way they were. <1,1,1> means a 180 twist? I just tried out different variations but I couldn't see much difference. Thanks very much again for your help!
  6. Hi once more. I'm slowly getting there. Today I managed to implement all functions in one script (in the original one). Thanks for your help! key avatar; integer handler; float range = 10.0; float rate = 10.0; list questions = [ //This is the quiz configuration. "\nQuestion #1: ... ?", "\nQuestion #2: ... ?", "\nQuestion #3: ... ?" ]; list responses = [ "yes, true, oui, 1", "no, false, non, 0", "Opensim, OpenSimulator" ]; integer random; string question() { integer count = llGetListLength(questions); random = (integer)llFrand((float)count); return llList2String(questions, random); } integer response(string response) { string csv = llList2String(responses, random); list buffer = llCSV2List(llToLower(csv)); if (~llListFindList(buffer, [llToLower(response)])) return TRUE; return FALSE; } //end of the quiz configuration //The next 3 variables determine where you will respawn when you are killed - instead of being TP'd to your home sim. string Destination; // Destination region is checked by the script on startup vector LandingPoint = <210,92,22.5>; //Change these coords as you wish - Set to the centre of the region now. vector LookAt = <1,1,1>; //Direction you will be looking at when you respawn string NotecardName; float Range; list Sayings = ["Chomps","Slurrps","Crunches","Nom Noms","Tastes","Bites","Licks","Gnaws","Chews","Grinds","Sucks","Nibbles"]; list Bits = ["Nose","Hand","Arm","Leg","Ass","Head","Foot","Ear","Chest","Stomach","Thighs"]; integer SayingsNr; integer BitsNr; key npc; key id; integer n; vector npcPos; key Target; vector toucherPos; vector TargetPos; vector Pos; float Position; integer Inc = 0; integer DeathInc = 0; integer DeathPoints=0; integer BiteInc = 0; integer Timer = 300; string TargetName; float Health; integer CHAN; string DeathAnim = "LB-belly3"; string CrouchAnim = "avatar_crouch"; string ZombieWalk = "Zombie_Walk"; string IdleAnim = "idle_1"; string ObjDes; integer channel=500; list Zombie=["Female 1","Female 2","Flame","Ghost","Reaper","Male"];//If you change the NPC notecards, change the name here list SenseRange=["10","15","20","30","50","96"];//Initial sensor range list HitPoints=["One","Two","Five","Ten","Twenty","Fifty"];//How many shots it takes to kill a zombie integer hex2int(string hex) { return(integer)("0x"+hex); } DelNPC() { osNpcRemove(npc); } default { state_entry() { Destination = llGetRegionName(); llSetAlpha(1.0,ALL_SIDES); llMessageLinked(LINK_SET, 1,"B",""); CHAN = 0; DeathInc = 0; Inc = 0; BiteInc = 0; DelNPC(); llSetText("",<0,1,1>,1.0); llListen(channel, "", NULL_KEY, ""); } changed(integer change) { if(change & 1024) { llResetScript(); } } touch_start(integer ok) //<------ This is what I would like to change into something automatic, { //for example "state_entry" or something like that. id = llDetectedKey(0) ; llDialog(id, "Zombie Type ?", Zombie, channel); } listen(integer channel, string name, key id, string message) { if (llListFindList(Zombie+SenseRange+HitPoints, [message]) != -1) { if(message == "Female 1") { NotecardName = "Female 1"; llDialog(id, "Sensing Range ?", SenseRange, channel); } if(message == "Female 2") { NotecardName = "Female 2"; llDialog(id, "Sensing Range ?", SenseRange, channel); } if(message == "Flame") { NotecardName = "Flame"; llDialog(id, "Sensing Range ?", SenseRange, channel); } if(message == "Ghost") { NotecardName = "Ghost"; llDialog(id, "Sensing Range ?", SenseRange, channel); } if(message == "Reaper") { NotecardName = "Reaper"; llDialog(id, "Sensing Range ?", SenseRange, channel); } if(message == "Male") { NotecardName = "Male"; llDialog(id, "Sensing Range ?", SenseRange, channel); } if(message == "10") { Range = 10.0; llDialog(id, "Zombie Max Hits till Death ?", HitPoints, channel); } if(message == "15") { Range = 15.0; llDialog(id, "Zombie Max Hits till Death ?", HitPoints, channel); } if(message == "20") { Range = 20.0; llDialog(id, "Zombie Max Hits till Death ?", HitPoints, channel); } if(message == "30") { Range = 30.0; llDialog(id, "Zombie Max Hits till Death ?", HitPoints, channel); } if(message == "50") { Range = 50.0; llDialog(id, "Zombie Max Hits till Death ?", HitPoints, channel); } if(message == "96") { Range = 96.0; llDialog(id, "Zombie Max Hits till Death ?", HitPoints, channel); } if(message == "One") { DeathPoints = 1; state Sense; } if(message == "Two") { DeathPoints = 2; state Sense; } if(message == "Five") { DeathPoints = 5; state Sense; } if(message == "Ten") { DeathPoints = 10; state Sense; } if(message == "Twenty") { DeathPoints = 20; state Sense; } if(message == "Fifty") { DeathPoints = 50; state Sense; } } } } state Sense { state_entry() { llMessageLinked(LINK_SET, 3,"B",""); llSetText("",<0,1,1>,1.0); DeathInc = 0; Inc = 0; BiteInc = 0; llSetAlpha(0.0,ALL_SIDES); llSensorRepeat("","",AGENT,Range,PI,1.0); } touch_start(integer number) { osNpcStand(npc); llSleep(1.0); osNpcRemove(npc); llOwnerSay("Zombie Rezzer RESET"); state default; } sensor(integer num) { integer i; for (i = 0; i < num; i ++) { Target = llDetectedKey(i); Health = osGetHealth(Target); TargetPos = llDetectedPos(i); Pos = llGetPos(); Position = llVecDist(TargetPos,Pos); llSensorRemove(); npcPos = llGetPos() + <0,0,0>; npc = osNpcCreate(NotecardName, "...", npcPos, NotecardName); state NPC_SIT; } } } state NPC_SIT { state_entry() { osNpcSayTo(npc, id, PUBLIC_CHANNEL, question()); //This is where the quiz question is asked by the zombie. handler = llListen(PUBLIC_CHANNEL, "", avatar, ""); //Here he listens for the reply. llSensorRepeat("","",AGENT,96,PI,2.0); llSetText("",<1,0,0>,1.0); SayingsNr = llGetListLength(Sayings); BitsNr = llGetListLength(Bits); llPreloadSound("Growl"); llPreloadSound("Scream2"); llPreloadSound("scream1"); llSetTimerEvent(10.0); CHAN = hex2int(llGetSubString(npc,0,7)); //end of the quiz question part. if (CHAN < 0) { CHAN = -CHAN; } //llOwnerSay("NPC Key is: "+(string)npc+"\nNPC Channel is: "+(string)channel); llListen(CHAN, "", "", ""); } listen(integer channel, string name, key OurIDs, string message) { if (id == handler) //Here the reply is matched with the respective question. { message = llStringTrim(message, STRING_TRIM); if (response(message) == TRUE) { llListenRemove(handler); osNpcSayTo(npc, id, PUBLIC_CHANNEL, "You win " + name); llSensorRepeat("", "", AGENT_BY_LEGACY_NAME, range, PI, rate * 2.0); llSetTimerEvent(0.0); llSensorRemove(); osNpcStopMoveToTarget(npc); osNpcStand(npc); osNpcPlayAnimation(npc,DeathAnim); llPlaySound("scream1",1.0); llSleep(5.0); llRegionSay(111,"Dead_Zombie"); llRegionSay(112,(string)llKey2Name(Target)); osNpcRemove(npc); //If the reply is correct, the zombie dies. state Sense; //The script goes back to the "Sense" state above. //llResetScript(); //This means a new zombie is being rezzed. } } if(channel == CHAN && message == "NPC") { osNpcStopMoveToTarget(npc); osNpcStand(npc); DeathInc = DeathInc +1; if(DeathInc<=DeathPoints) { llPlaySound("Scream2",1.0); } osAvatarPlayAnimation(npc,IdleAnim); osAvatarPlayAnimation(npc,CrouchAnim); llSleep(1.25); if(DeathInc>=DeathPoints) { llSetTimerEvent(0.0); llSensorRemove(); osNpcStopMoveToTarget(npc); osNpcStand(npc); osNpcPlayAnimation(npc,DeathAnim); llPlaySound("scream1",1.0); llSleep(5.0); llRegionSay(111,"Dead_Zombie"); llRegionSay(112,(string)llKey2Name(Target)); osNpcRemove(npc); state Sense; //llResetScript(); } llSleep(0.25); osNpcPlayAnimation(npc,ZombieWalk); } } sensor(integer num) { integer i; for (i = 0; i < num; i ++) { llSleep(0.5); Target = llDetectedKey(i); Health = osGetHealth(Target); TargetName = llDetectedName(i); toucherPos = llDetectedPos(i); npcPos = osNpcGetPos(npc); Position = llVecDist(toucherPos, npcPos); if (Position>1.0) { osNpcMoveToTarget(npc,toucherPos+<0,0,0>, OS_NPC_NO_FLY); } if (Position<3.0) { osTeleportAgent(Target, Destination, LandingPoint, LookAt); osNpcRemove(npc); state Sense; if(Health<=35.0) { if(BiteInc >=1 ) { llRegionSay(111,"Dead"); BiteInc = 0; } osNpcSay(npc,"Hahaha.. You Died !!"); osCauseHealing(Target, 50); } llRegionSay(112,(string)llKey2Name(Target)); float FSaid = llFrand(SayingsNr); integer Said = llCeil(FSaid)-1; string Text = llList2String(Sayings,Said); float FSaid1 = llFrand(BitsNr); integer Said1 = llCeil(FSaid1)-1; string Text1 = llList2String(Bits,Said1); osNpcSay(npc,(string)Text+" "+(string)llKey2Name(Target)+"'s "+(string)Text1); BiteInc = BiteInc + 1; osCauseDamage(Target, 10.0); llRegionSay(111,"Bite"); llSleep(2.0); } } } touch_start(integer number) { osNpcStand(npc); llSleep(1.0); osNpcRemove(npc); llOwnerSay("Zombie Rezzer RESET"); state default; } timer() { Inc = Inc +10; integer Del = Timer-Inc; llSetText("Auto-Delete in "+(string)Del+" seconds",<1,0,0>,1.0); float Rand1 = llFrand(2.0); if(Rand1>= 1.0) { llPlaySound("Growl",1.0); } if(Inc>=Timer) { osNpcRemove(npc); state Sense; //llResetScript(); } } }
  7. That's a nice idea. Unfortunately, Opensim / Osgrid does not offer that option, I just tried it. Second life has some nice scripting options that we don't have, unfortunately. Thanks, though.
  8. No, that's actually a great idea. I wasn't advanced enough in scripting back then, when I did that. I'll look into that. I'm still a bit of a newbie. My scripts are usually a collage of other people's scripts. 😉
  9. Yes, I tried it in a different task. It's neat. Text tasks in general are a bit painful in OS / SL. Haven't found the perfect solutions yet.
  10. That's a good point. Might make it more convenient.
  11. Thanks for the tip. I'll try that. I know about the frustration when typing the word wrong. I'm going to use it for simple words first. The dialog might be a good alternative for more complex questions. I'll come back for help when I get stuck. 🙂
  12. I tried that. Worked at first but then all of a sudden didn't any more. I don't know why. I would like to use both options. Typing the answer directly also makes it necessary to spell it correctly, which can be useful for vocabulary learning. I want to use it for education.
  13. Good idea. That might save some lines of code. Overall, though, the problem is less the randomization of the questions than to make the corresponding answer match them.
  14. Thank you for your help. The questions are always displayed correctly as strings in the chat. I also typed in some real questions instead of "...", to test them. Is that what you meant?
  15. Thanks for your support! I've been somewhat successful, even though the scripts are a bit flawed. This one's for an NPC: float Position; key id; vector npcPos; vector agent_pos; vector Pos; // Simple Sensor Quizz III v0.1 by djphil (CC-BY-NC-SA 4.0) integer teleport = TRUE; vector position = <128.0, 128.0, 25.0>; float range = 10.0; float rate = 2.0; list questions = [ "\nQuestion #1: ... ?", "\nQuestion #2: ... ?", "\nQuestion #3: ... ?" ]; list responses = [ "yes, true, oui, 1", "no, false, non, 0", "Opensim, OpenSimulator" ]; key avatar; list avatars; integer random; integer counter; integer handler; key zombie; vector inipos; string question() { integer count = llGetListLength(questions); random = (integer)llFrand((float)count); return llList2String(questions, random); } integer response(string response) { string csv = llList2String(responses, random); list buffer = llCSV2List(llToLower(csv)); if (~llListFindList(buffer, [llToLower(response)])) return TRUE; return FALSE; } default { state_entry() { if (llGetInventoryName(INVENTORY_NOTECARD, 0) != "appearance") osOwnerSaveAppearance("appearance"); inipos = llGetPos() + <0.5, 0.0, 1.0>; llSensorRepeat("", "", AGENT_BY_LEGACY_NAME, range, PI, rate); llSetText("", <1.0, 1.0, 1.0>, 1.0); } sensor(integer n) { if (counter > 4) { llListenRemove(handler); llSetStatus(STATUS_PHANTOM, FALSE); llRegionSayTo(avatar, PUBLIC_CHANNEL, "You loze " + llKey2Name(avatar)); if (teleport == TRUE) llTeleportAgent(avatar, "", position, ZERO_VECTOR); llSensorRepeat("", "", AGENT_BY_LEGACY_NAME, range, PI, rate * 2.0); llSetText("", <1.0, 1.0, 1.0>, 1.0); llSetAlpha(1.0, ALL_SIDES); osNpcRemove(zombie); avatars = []; counter = 0; } integer i; for (i = 0; i < n; i ++) { rotation agent_rote = llDetectedRot(i); vector agent_pos = llDetectedPos(i); avatar = llDetectedKey(i); agent_pos = llDetectedPos(i); npcPos = osNpcGetPos(zombie); Position = llVecDist(agent_pos, npcPos); if (Position>1.0) { osNpcMoveToTarget(zombie,agent_pos, OS_NPC_NO_FLY ); avatar = llDetectedKey(i); if (!~llListFindList(avatars, [avatar])) { if (llGetListLength(avatars) < 1) { avatars += avatar; llSetAlpha(1.0, ALL_SIDES); llSetStatus(STATUS_PHANTOM, FALSE); vector agent_pose = llDetectedPos(i); //rotation agent_rote = llDetectedRot(i); vector offset = <1.0, 0.0, 0.0>; offset = offset * agent_rote; agent_pose += offset; zombie = osNpcCreate("NPC", "Zombie", inipos, "appearance"); osNpcSetRot(zombie, agent_rote * llEuler2Rot(<0.0, 0.0, 180.0> * DEG_TO_RAD)); osNpcSayTo(zombie, avatar, PUBLIC_CHANNEL, question()); handler = llListen(PUBLIC_CHANNEL, "", avatar, ""); llSetText(llKey2Name(avatar), <1.0, 1.0, 1.0>, 1.0); } else if (!~llListFindList(avatars, [avatar])) { osNpcSayTo(zombie, avatar, PUBLIC_CHANNEL, "Sorry " + llKey2Name(avatar) + ", the game is buzy ..."); } } } ++counter; } } no_sensor() { avatars = []; counter = 0; osNpcRemove(zombie); llSetAlpha(1.0, ALL_SIDES); llSetText("", <1.0, 1.0, 1.0>, 1.0); } listen(integer channel, string name, key uuid, string message) { if (uuid == handler) { message = llStringTrim(message, STRING_TRIM); if (response(message) == TRUE) { counter = 0; avatars = []; llListenRemove(handler); osNpcSayTo(zombie, uuid, PUBLIC_CHANNEL, "You win " + name); llSetText("", <1.0, 1.0, 1.0>, 1.0); llSensorRepeat("", "", AGENT_BY_LEGACY_NAME, range, PI, rate * 2.0); llSetStatus(STATUS_PHANTOM, TRUE); llSetAlpha(0.25, ALL_SIDES); osNpcRemove(zombie); } } } on_rez(integer n) {llResetScript();} } ... and one for a prim-zombie: float Position; key id; vector npcPos; vector agent_pos; vector Pos; // Simple Sensor Quizz III v0.1 by djphil (CC-BY-NC-SA 4.0) integer teleport = TRUE; vector position = <128.0, 128.0, 25.0>; float range = 10.0; float rate = 10.0; list questions = [ "\nQuestion #1: ... ?", "\nQuestion #2: ... ?", "\nQuestion #3: ... ?" ]; list responses = [ "yes, true, oui, 1", "no, false, non, 0", "Opensim, OpenSimulator" ]; key avatar; list avatars; integer random; integer handler; key zombie; vector inipos; string question() { integer count = llGetListLength(questions); random = (integer)llFrand((float)count); return llList2String(questions, random); } integer response(string response) { string csv = llList2String(responses, random); list buffer = llCSV2List(llToLower(csv)); if (~llListFindList(buffer, [llToLower(response)])) return TRUE; return FALSE; } default { state_entry() { llSensorRepeat("", "", AGENT_BY_LEGACY_NAME, range, PI, rate); } sensor(integer n) { integer i; for (i = 0; i < n; i ++) { rotation agent_rote = llDetectedRot(i); vector agent_pos = llDetectedPos(i); avatar = llDetectedKey(i); agent_pos = llDetectedPos(i); npcPos = llGetPos(); Position = llVecDist(agent_pos, npcPos); if (Position<2) { llListenRemove(handler); llRegionSayTo(avatar, PUBLIC_CHANNEL, "You lose " + llKey2Name(avatar)); if (teleport == TRUE) llTeleportAgent(avatar, "", position, ZERO_VECTOR); llSensorRepeat("", "", AGENT_BY_LEGACY_NAME, range, PI, rate * 2.0); } if (Position<6.0) { llRegionSayTo(avatar, PUBLIC_CHANNEL, question()); handler = llListen(PUBLIC_CHANNEL, "", avatar, ""); } } } no_sensor() { } listen(integer channel, string name, key uuid, string message) { if (uuid == handler) { message = llStringTrim(message, STRING_TRIM); if (response(message) == TRUE) { avatars = []; llListenRemove(handler); llRegionSayTo(uuid, PUBLIC_CHANNEL, "You win " + name); //llSetText("", <1.0, 1.0, 1.0>, 1.0); //llSensorRepeat("", "", AGENT_BY_LEGACY_NAME, range, PI, rate * 2.0); llDie(); } } } on_rez(integer n) {llResetScript();} } In case anyone has ideas of improvement, feel free to reply. Thanks!
×
×
  • Create New...