Jump to content

testgenord1

Resident
  • Content Count

    29
  • Joined

  • Last visited

Community Reputation

1 Neutral

About testgenord1

  • Rank
    Member

Recent Profile Visitors

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

  1. Thank you very much for your tip. That, apparently, was the problem. I deleted the states and now have only one script. It's still far from perfect, I guess, but it works, at least on OSGrid / OpenSim. Thank you very much again! integer tick; float move; vector oldPosition; list insults = [ "You are a loser! Ha, ha!", "You can't drive! He, he!", "I'm much better than you!", "I will win!", "You will lose! Ha, ha, ha!" ]; integer random; string insult() { integer count = llGetListLength(insults); random = (integer)llFrand((float)count); return llList2String(insults, random); } default { on_rez(integer start_param) { oldPosition = llGetPos(); llSetText("Johnny Craft ", <1.0,1.0,1.0>, 1.0); llListen(-799,"", NULL_KEY, ""); } listen(integer channel, string name, key id, string message) { if (message == "start") { llSay(0,"\n\n"+insult()); } if (message == "reset") { tick = 0; move = 0; llSetPos(oldPosition); llResetScript(); llSleep(5.0); llStopSound(); llDie(); } oldPosition = llGetPos(); llSetTimerEvent(10.0); } timer() { ++tick; move += 2; if (tick > 10) { llSetPos((oldPosition) + <move, 0.0, 0.0>); llRegionSay(-799,"reset"); llRegionSay(-798,"fireworks"); llLoopSound("cheer-hooter-01",1.0); llSay(0,"\n\nI'm the winner!!!!\n\nYou lose!!!\n\nHa, ha, ha!!!"); //llPlaySound("cheer-hooter-01",1.0); tick = 0; move = 0; llSleep(20.0); llRegionSay(-798,"fireworks"); llSleep(12.0); llSetPos(oldPosition); llSleep(5.0); llDie(); } else { llPlaySound("s_rev",1.0); llSleep(2.0); llSetPos((oldPosition) + <move, 0.0, 0.0>); } } }
  2. Continuation: I've added an automatic / npc car as an opponent and correspondingly adjusted the player's car script. The npc car just slowly drives forward in intervals through a timer / counter. Once npc the car has reached a certain number in the counter (here: "more than 10"), the npc car has won the race and the player has lost. Then, the npc car sends the message "reset" to the player's car, and the player's car stops and goes back to its initial position ("oldPosition"). Should the player answer all quiz questions correctly before this happens, the player has won. In that case, the player's car sends the message "reset" to the npc car, which now is supposed to stop moving and go back to its initial position ("oldPosition"). However, although the player's car reacts correctly on the message "reset", the npc car doesn't. It keeps moving regardless. Hence, I added an extra script, resetting the npc car script and setting it back to its initial position, which now works. Still, I'm curious why the message "reset" stops the player's car, but not the npc car, although the scripts as such are very similar. I'm posting the scripts below: player's car: // Simple Sensor Quizz I v0.1 by djphil (CC-BY-NC-SA 4.0) + Prim Computer v0.1 by djphil (CC-BY-NC-SA 4.0) list lSounds = [ "6e517cde-066f-455e-8c6b-f1c33be90dea", "611c9470-507e-4471-8ce2-5ed0962e4c85", "b1e78aa1-52b7-482f-a48a-57e3ddff81fc", "7b978d05-b3bd-4e6f-892f-92dc4845ddd8", "64319812-dab1-4e89-b1ca-5fc937b8d94a", "720ff3dd-8fc6-4523-9670-139df57527f3"]; integer tick; float move; vector oldPosition; list questions = [ "Was heißt auf Englisch: \n\nessen", "Was heißt auf Englisch: \n\ntrinken", "Was heißt auf Englisch: \n\ngehen \n(2 Buchstaben)", "Was heißt auf Englisch: \n\ngehen \n(4 Buchstaben)", "Was heißt auf Englisch: \n\nrennen", "Was heißt auf Englisch: \n\nfahren", "Was heißt auf Englisch: \n\nfliegen", "Was heißt auf Englisch: \n\nschlafen", "Was heißt auf Englisch: \n\ndenken", "Was heißt auf Englisch: \n\nmögen", "Was heißt auf Englisch: \n\nhaben", "Was heißt auf Englisch: \n\nverlieren", "Was heißt auf Englisch: \n\ngewinnen", "Was heißt auf Englisch: \n\nleben", "Was heißt auf Englisch: \n\nverstehen", "Was heißt auf Englisch: \n\nwissen" ]; list responses = [ "eat", "drink", "go", "walk", "run", "drive", "fly", "sleep", "think", "like", "have", "lose", "win", "live", "understand", "know" ]; 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; } default { on_rez(integer start_param) { oldPosition = llGetPos(); } touch_start(integer num) { llPlaySound("s_rev",1.0); llRegionSay(-799,"start"); state listening; } } state listening { state_entry() { llSetTimerEvent(8.0); } timer() { llSay(0, "\n\nSchreibe die Antwort in den Chat.\n\n" + question()); llListen(PUBLIC_CHANNEL,"", NULL_KEY, ""); llListen(-799,"", NULL_KEY, ""); } listen(integer channel, string name, key id, string message) { if (response(message) == TRUE) { llSay(0, "\n\nThat's correct, " + name + "!"); llPlaySound("s_rev",1.0); state moving; } if (message == "reset") { llSetPos(oldPosition); tick = 0; move = 0; llSleep(12.0); //llStopSound(); //state default; llDie(); } if (response(message) == FALSE) { tick = 0; move = 0; integer iWhichOne = (integer) llFrand( llGetListLength( lSounds ) ); llPlaySound( llList2String(lSounds, iWhichOne), 1.0); llSay(0,"\n\n\nThat's wrong, " + name + "! \n\n\n(Du musst wieder auf das Auto klicken.)"); llSetPos(oldPosition); key user = llAvatarOnSitTarget(); // Store the UUID of any agent sitting on the sit target. llUnSit(user); state default; } } } state moving { state_entry() { llSetTimerEvent(2.0); } timer() { ++tick; move += 4; if (tick > 5) { llSetPos((oldPosition) + <move, 0.0, 0.0>); tick = 0; move = 0; llRegionSay(-798,"fireworks"); llLoopSound("cheer-hooter-01",1.0); llSay(0,"\n\nYou have won!!!"); llRegionSay(-799,"reset"); llSleep(10.0); llRegionSay(-798,"fireworks"); llSleep(12.0); llSetPos(oldPosition); llSleep(5.0); //llStopSound(); //state default; llDie(); } else { llSetPos((oldPosition) + <move, 0.0, 0.0>); state listening; } } } npc car script: integer tick; float move; vector oldPosition; list insults = [ "You are a loser! Ha, ha!", "You can't drive! He, he!", "I'm much better than you!", "I will win!", "You will lose! Ha, ha, ha!" ]; integer random; string insult() { integer count = llGetListLength(insults); random = (integer)llFrand((float)count); return llList2String(insults, random); } default { on_rez(integer start_param) { oldPosition = llGetPos(); llSetText("Johnny Craft ", <1.0,1.0,1.0>, 1.0); state listening; } } state listening { state_entry() { llListen(-799,"", NULL_KEY, ""); } listen(integer channel, string name, key id, string message) { if (message == "start") { llSay(0,"\n\n"+insult()); state moving; } //if (message == "reset") //{ //tick = 0; //move = 0; //llSetPos(oldPosition); //llResetScript(); //llSleep(5.0); //llStopSound(); //llDie(); //} } } state moving { state_entry() { oldPosition = llGetPos(); llSetTimerEvent(18.0); } timer() { ++tick; move += 2; if (tick > 10) { llSetPos((oldPosition) + <move, 0.0, 0.0>); llRegionSay(-799,"reset"); llRegionSay(-798,"fireworks"); llLoopSound("cheer-hooter-01",1.0); llSay(0,"\n\nI'm the winner!!!!\n\nYou lose!!!\n\nHa, ha, ha!!!"); tick = 0; move = 0; llSleep(10.0); llRegionSay(-798,"fireworks"); llSleep(12.0); llSetPos(oldPosition); llSleep(5.0); //llStopSound(); llDie(); } else { llPlaySound("s_rev",1.0); llSetPos((oldPosition) + <move, 0.0, 0.0>); state moving; } } } extra npc car reset script: vector oldPosition; default { on_rez(integer start_param) { oldPosition = llGetPos(); llListen(-799,"", NULL_KEY, ""); } listen(integer channel, string name, key id, string message) { if (message == "reset") { llResetOtherScript("npc car script"); llSetPos(oldPosition); llSleep(12.0); llDie(); } } } Here is the part that isn't working in the npc car script: //if (message == "reset") //{ //tick = 0; //move = 0; //llSetPos(oldPosition); //llResetScript(); //llSleep(5.0); //llStopSound(); //state default; //llDie(); //} Do you maybe have any idea why this isn't working? Thank you very much in advance, and please excuse flaws in the scripts, I'm still learning.
  3. I eventually came up with a simpler version than the one above. It simply uses llSetPos and llGetPos. There is always room for improvement, so feel free to comment. Thanks very much for your help, roligloon! Here is the script: // Simple Sensor Quizz I v0.1 by djphil (CC-BY-NC-SA 4.0) + Prim Computer v0.1 by djphil (CC-BY-NC-SA 4.0) integer tick; float move; vector oldPosition; list questions = [ "Was heißt auf Englisch: \n\nessen", "Was heißt auf Englisch: \n\ntrinken", "Was heißt auf Englisch: \n\ngehen \n(2 Buchstaben)", "Was heißt auf Englisch: \n\ngehen \n(4 Buchstaben)", "Was heißt auf Englisch: \n\nrennen", "Was heißt auf Englisch: \n\nfahren", "Was heißt auf Englisch: \n\nfliegen", "Was heißt auf Englisch: \n\nschlafen", "Was heißt auf Englisch: \n\ndenken", "Was heißt auf Englisch: \n\nmögen", "Was heißt auf Englisch: \n\nhaben", "Was heißt auf Englisch: \n\nverlieren", "Was heißt auf Englisch: \n\ngewinnen", "Was heißt auf Englisch: \n\nleben", "Was heißt auf Englisch: \n\nverstehen", "Was heißt auf Englisch: \n\nwissen" ]; list responses = [ "eat", "drink", "go", "walk", "run", "drive", "fly", "sleep", "think", "like", "have", "lose", "win", "live", "understand", "know" ]; 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; } default { state_entry() { oldPosition = llGetPos(); } touch_start(integer num) { state listening; } } state listening { state_entry() { llSay(0, "\n\nSchreibe die Antwort in den Chat.\n\n" + question()); llListen(PUBLIC_CHANNEL,"", NULL_KEY, ""); llListen(-799,"", NULL_KEY, ""); } listen(integer channel, string name, key id, string message) { if (response(message) == TRUE) { llSay(0, "\n\nThat's correct, " + name + "!"); state moving; } else { tick = 0; move = 0; llPlaySound("64319812-dab1-4e89-b1ca-5fc937b8d94a",1.0); llSetPos(oldPosition); state default; } } } state moving { state_entry() { llSetTimerEvent(2.0); } timer() { ++tick; move += 2; if (tick > 2) { llSetPos((oldPosition) + <move, 0.0, 0.0>); llPlaySound("ed124764-705d-d497-167a-182cd9fa2e6c",1.0); llSay(0,"\n\nYou have won!!!"); tick = 0; move = 0; llSetPos(oldPosition); state default; } else { llSetPos((oldPosition) + <move, 0.0, 0.0>); state listening; } } }
  4. Hi again! Just tried out all improvements. Unfortunately, there is a different problem now, which is, with each correct reply to the questions, the linkset-vehicle moves along the negative y-axis, no matter how you change the coordinates by using the "move" variable. Besides, the linkset-vehicle does not return to its initial starting position after the "ticks" number of correct reply, but keeps moving in the same direction. I'm posting the script including the changes below. In case any of you can help, please let me know. 🙂 Thanks very much in advance! // Simple Sensor Quizz I v0.1 by djphil (CC-BY-NC-SA 4.0) + Prim Computer v0.1 by djphil (CC-BY-NC-SA 4.0) integer iSelf; integer tick; float move; list questions = [ "Was heißt auf Englisch: \n\nessen", "Was heißt auf Englisch: \n\ntrinken", "Was heißt auf Englisch: \n\ngehen \n(2 Buchstaben)", "Was heißt auf Englisch: \n\ngehen \n(4 Buchstaben)", "Was heißt auf Englisch: \n\nrennen", "Was heißt auf Englisch: \n\nfahren", "Was heißt auf Englisch: \n\nfliegen", "Was heißt auf Englisch: \n\nschlafen", "Was heißt auf Englisch: \n\ndenken", "Was heißt auf Englisch: \n\nmögen", "Was heißt auf Englisch: \n\nhaben", "Was heißt auf Englisch: \n\nverlieren", "Was heißt auf Englisch: \n\ngewinnen", "Was heißt auf Englisch: \n\nleben", "Was heißt auf Englisch: \n\nverstehen", "Was heißt auf Englisch: \n\nwissen" ]; list responses = [ "eat", "drink", "go", "walk", "run", "drive", "fly", "sleep", "think", "like", "have", "lose", "win", "live", "understand", "know" ]; 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; } default { state_entry() { llSetLinkPrimitiveParamsFast(1, [PRIM_POS_LOCAL, <0.0,0.0,0.0>]); } touch_start(integer num) { state listening; } } state listening { state_entry() { llSay(0, "\n\nSchreibe die Antwort in den Chat.\n\n" + question()); llListen(PUBLIC_CHANNEL,"", NULL_KEY, ""); llListen(-799,"", NULL_KEY, ""); //This can be used by a reset button. } listen(integer channel, string name, key id, string message) { if (response(message) == TRUE) { llSay(0, "That's correct, " + name + "!"); state moving; } else { llResetScript(); } } } state moving { state_entry() { llSetTimerEvent(2.0); iSelf = llGetNumberOfPrims(); // Be sure to declare iSelf as a global integer variable. } timer() { ++tick; move += 2; llSetLinkPrimitiveParamsFast(LINK_SET,[34,1,PRIM_POS_LOCAL,<0.0,move,0.0>, 34,iSelf,PRIM_POS_LOCAL,<0.0,move,0.0>]); if (tick > 3) { tick = 0; move = 0; llPlaySound("ed124764-705d-d497-167a-182cd9fa2e6c",1.0); llSleep(2.0); state default; } state listening; } }
  5. Thank you very much for your quick help! 🙂 I've only tested it in an offline version of OpenSim so far, and the online test might show different results, but it basically works. One little problem remained, and that is, not only the avatar, but also his / her vehicle is supposed to be moved, so the avatar seems to be "driving" the car. I used a workaround, even though it might not be the most elegant way: I simply repeated your line moving the avatar and this time I filled in the number for the actual child prim ("2") instead of "iSelf". (the line before the last line in the script). It seems to work so far, so I'll test it some more online during the week. Should I run into more trouble, I'll come around again. Thanks again! 🙂 state moving { state_entry() { llSetTimerEvent(2.0); iSelf = llGetNumberOfPrims(); // Be sure to declare iSelf as a global integer variable. } timer() { ++tick; move += 2; llSetLinkPrimitiveParamsFast(2, [PRIM_POS_LOCAL, <0.0, move, 0.0>]); llSetLinkPrimitiveParamsFast(iSelf, [PRIM_POS_LOCAL, <0.0, move, 0.5>]);
  6. Hi! I've made a vocabulary quiz game: - The player sits on a car. - He is asked vocabulary questions through the chat. - With each correct answer, he / she moves forward some meters on the car. - A wrong answer moves the car back to its initial starting position. - He / she plays against other players or NPCs / prims. - The player who goes through the finish line first wins. - Afterwards, the "car" goes back to its initial starting position. The script works (OpenSim/ OSGrid). One problem remains: I'm using llSetLinkPrimitiveParamsFast to change the position of the car. The script moves the child prim. Now, it is not possible to remain sitting on that moving child prim. The prim keeps moving without you sitting on it. It is possible to remain sitting on the moving root prim when the script moves the root prim instead of the child prim. In that case, though, the position of the root prim must be given in a fixed absolute vector at the beginning of the script, which is less flexible than the child-prim version, which uses a position relative to the root prim. I also tried out llSetKeyframdedMotion but using that, I haven't been able to return to the initial starting position at the end of the game. The ideal solution would be a child-prim which is "ride-able". Do you maybe have an idea of how to achieve that? Thank you very much in advance. Here is the script: // Simple Sensor Quizz I v0.1 by djphil (CC-BY-NC-SA 4.0) + Prim Computer v0.1 by djphil (CC-BY-NC-SA 4.0) integer tick; float move; list questions = [ "Was heißt auf Englisch: \n\nessen", "Was heißt auf Englisch: \n\ntrinken", "Was heißt auf Englisch: \n\ngehen \n(2 Buchstaben)", "Was heißt auf Englisch: \n\ngehen \n(4 Buchstaben)", "Was heißt auf Englisch: \n\nrennen", "Was heißt auf Englisch: \n\nfahren", "Was heißt auf Englisch: \n\nfliegen", "Was heißt auf Englisch: \n\nschlafen", "Was heißt auf Englisch: \n\ndenken", "Was heißt auf Englisch: \n\nmögen", "Was heißt auf Englisch: \n\nhaben", "Was heißt auf Englisch: \n\nverlieren", "Was heißt auf Englisch: \n\ngewinnen", "Was heißt auf Englisch: \n\nleben", "Was heißt auf Englisch: \n\nverstehen", "Was heißt auf Englisch: \n\nwissen" ]; list responses = [ "eat", "drink", "go", "walk", "run", "drive", "fly", "sleep", "think", "like", "have", "lose", "win", "live", "understand", "know" ]; 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; } default { state_entry() { llSetLinkPrimitiveParamsFast(2, [PRIM_POS_LOCAL, <0.5,0.0,0.0>]); } touch_start(integer num) { state listening; } } state listening { state_entry() { llSay(0, "\n\nSchreibe die Antwort in den Chat.\n\n" + question()); llListen(PUBLIC_CHANNEL,"", NULL_KEY, ""); llListen(-799,"", NULL_KEY, ""); //This can be used by a reset button. } listen(integer channel, string name, key id, string message) { if (response(message) == TRUE) { llSay(0, "That's correct, " + name + "!"); state moving; } else { llResetScript(); } } } state moving { state_entry() { llSetTimerEvent(2.0); } timer() { ++tick; move += 2; llSetLinkPrimitiveParamsFast(2, [PRIM_POS_LOCAL, <move, 0.0, 0.0>]); if (tick > 3) { tick = 0; move = 0; llPlaySound("ed124764-705d-d497-167a-182cd9fa2e6c",1.0); llSleep(5.0); state default; } state listening; } }
  7. Interesting. So the llGetSubString  would "cut off" the differing prefixes of the names of the two matching cards and thus turn the 'English card' into: "[ENG_]Texture_Boat" (="Texture_Boat") and the 'French' matching card into: "[FRA_]Texture_Boat" (="Texture_Boat") and then they would actually match. Did I get this right? I'll have a look at this. Just have to find out how to do this yet. Thanks!
  8. Hi! I've made a memory game using textures. The memory cards start off with their textures in the colour black. When you click on a card, the colour of the texture changes from black to white and it thus becomes visible. When you click on another card the same thing happens. When you happen to click on two matching cards (having the same texture), you get the feedback "Well done!" /"matching card found" or something similar. (matching cards: texture 1 and texture 1) What I would like to change, however is the following: I would like to use this memory game as a vocabulary exercise. One card is supposed to display an English word A second card is supposed to display the same word in a different language. There is a texture for the English word and another texture for the same word in, e.g., French. This means the script would have to be adjusted in the following way: The cards that match each other would not be cards having the same texture, but they would have different textures. (matching cards: texture English and texture French) I guess this is hard to achieve. Do you maybe have an idea of how to do this? Thank you very much in advance. //written by Rebecca Davis and dj phil 05/25/2019; //https://www.youtube.com/watch?v=lCHt7dCEqJA //https://forums.osgrid.org/viewtopic.php?f=5&t=6353 list pics = []; list used = []; list done = []; integer debug = FALSE; integer tries; list select = []; string pic1; key user; list success = []; list chosen = []; list players = []; string playerlist; key current; fillPics() { integer i; integer all = llGetInventoryNumber(INVENTORY_TEXTURE); if(debug)llOwnerSay((string)all+" textures found"); for(i=0; i<all; i=i+1) { string add = llGetInventoryName(INVENTORY_TEXTURE,i); pics = pics + add; if(debug)llOwnerSay("Adding Texture "+add+" to Pics List"); } } populate() { integer all = llGetNumberOfPrims( ); integer this = llGetLinkNumber(); integer picCount = llGetListLength(pics); picCount=picCount-1; list used = []; list done = []; if(debug) llOwnerSay((string)all+" Number of parts. The Root is "+(string)this); integer i; llSetLinkColor(this, <1,1,1>, ALL_SIDES); for(i=this; i<all; i=i+1) { string thisPic = picSelect(picCount); llSetLinkTexture(i+1,thisPic,ALL_SIDES); llSetLinkColor(i+1, <0,0,0>, ALL_SIDES); //llSetLinkColor(i+1, <0,0,0>, ALL_SIDES); } } string picSelect(integer picCount) { user = llGetOwner(); integer nope = 1; string picName; while(nope != -1) { integer choose = llRound(llFrand(picCount)); picName= llList2String(pics,choose); nope = llListFindList(done,[picName]); integer last = llListFindList(used,[picName]); if(last != -1) done = done + picName; else used = used + picName; } return picName; } chooser(integer box) { string name = llKey2Name(user); llSetLinkColor(box,<1,1,1>, ALL_SIDES); select = select+box; if(llGetListLength(select)>1) { string pic2 = texture(box); if(pic1 == pic2) { llSay(0,"Well done, "+name+"!"+"\n\n"); chosen = chosen + box; box = llList2Integer(select,0); chosen = chosen + box; } else { //llSay(0,"Sorry that is not a match"); llSleep(3); if(llListFindList(chosen,[box]) == -1)llSetLinkColor(box,<0,0,0>, ALL_SIDES); box = llList2Integer(select,0); if(llListFindList(chosen,[box]) == -1)llSetLinkColor(box,<0,0,0>, ALL_SIDES); integer place = llListFindList(players, [current]); place = place +1; if(place < llGetListLength(players) ) current = llList2Key(players,place); else current = llList2Key(players,0); llSetText(playerlist+"\n\n It is "+llKey2Name(current)+"'s turn.\n\n", <1,1,1>, 1); } //llSay(0,name+" is done"); llSay(0,"Next player, please.\n\n"); select = []; pic1 = ""; return; } else { pic1 = texture(box); } } string texture(integer box) { list params = llGetLinkPrimitiveParams(box,[ PRIM_TEXTURE, 0]); string get = llList2String(params,0); return get; } add(key who) { players = players + who; string PlayersShow = ""; integer i; for(i=0; i<llGetListLength(players); i=i+1) { PlayersShow = PlayersShow + llKey2Name(llList2Key(players,i)); } playerlist = "players:\n"+PlayersShow; llSetText("players "+PlayersShow+"\nClick to join the game.\n\n", <1,1,1>, 1); } default { state_entry() { fillPics(); populate(); //llSay(0,"Click the board to sign up for this round"); llListen(0,"",NULL_KEY,"start"); llListen(0,"",NULL_KEY,"reset"); //llSetText("Current Players \n None \n \nclick to join game", <1,1,1>, 1); } listen(integer chan, string what, key who, string msg) { if(msg == "start")state play; else if(msg == "reset")llResetScript(); } touch_start(integer clicked) { add(llDetectedKey(0)); state play; } } state play { state_entry() { llSay(0,"Starting the game"+"\n\n"); llListen(0,"",NULL_KEY,"reset"); current = llList2Key(players,0); llSetText(playerlist+"\n\n It is "+llKey2Name(current)+"'s turn.\n\n", <1,1,1>, 1); } listen(integer chan, string what, key who, string msg) { if(msg == "reset")llResetScript(); } touch_start(integer total_number) { key clicked = llDetectedKey(0); if(clicked != current) { llInstantMessage(clicked,"Sorry, it is not your turn.\n\n"); return; } if(clicked != user) { llInstantMessage(clicked,"It is not your turn.\n\n"); return; } integer box = llDetectedLinkNumber(0); if(llListFindList(chosen,[box]) == -1) chooser(box); llSetTimerEvent(120); } timer() { llResetScript(); } }
  9. 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(); } }
  10. 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
  11. 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(); } } } } }
  12. Thanks for the suggestion! I'll try that.😊
  13. 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!
  14. 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(); } } }
  15. 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.
×
×
  • Create New...