Jump to content

testgenord1

Resident
  • Posts

    146
  • Joined

  • Last visited

Everything posted by testgenord1

  1. Thank you very much for your immediate replies! ๐Ÿ˜€ I really appreciate that. @Qie NiangaoI couldn't accomplish the PRIM_POS_LOCAL option, trying to make the button disappear in the console / root prim. I've read that llSetLinkPrimitiveParamsFast seems to have some issues with POSITION. Is that possible? The PRIM_TEXT option seems to work nicely, though, so thank you very much for that idea. I've used another work-around solution, which basically seems to do the trick, and that is, I made the script scale the button clicked to 0.01 in size, making it nearly impossible to click on. I hope this is doing the trick now (usually I find later that it doesn't. ๐Ÿ˜†). Should I run into more problems, I'll come back again. string region; key user; string nameuser; integer linknum; list tasks = [<975.00,29.00,24.00>,"destination1", <861.00,105.00,24.00>,"destination2", <842.00,118.00,24.00>,"destination3", <676,17.00,24.00>,"destination4", <1000.00,417.00,24.00>,"destination5", <717.00,652.00,24.00>,"destination6", <963.00,682.00,24.00>,"destination7", <807.00,677.00,24.00>,"destination8"]; list positions; vector pos; vector lookat = <0.0,0.0,0.0>; integer listlength; integer linkstotal; integer seconds; integer interval = 180; list ltext; string stext; default { state_entry() { llSetTimerEvent(1.0); linkstotal = llGetNumberOfPrims(); integer i; for(i=2; i<=linkstotal; ++i) llSetLinkPrimitiveParamsFast(i,[PRIM_COLOR,ALL_SIDES,<1.0,1.0,1.0>,0.0, PRIM_SIZE,<0.01,0.01,0.01>]); ltext = llList2ListStrided(llDeleteSubList(tasks,0,0),0,-1,2); region = llGetRegionName(); positions = llList2ListStrided(tasks,0,-1,2); //llOwnerSay("listlength = " + (string)listlength); //llOwnerSay("linkstotal =" + (string)linkstotal); integer listlength = llGetListLength(positions); integer j; for(j=2; j<=listlength; ++j) llSetLinkPrimitiveParamsFast(j,[PRIM_COLOR,ALL_SIDES,<1.0,1.0,1.0>,1.0, PRIM_SIZE,<0.5,0.5,0.5>]); } touch_start(integer num) { user = llDetectedKey(0); nameuser = llDetectedName(0); integer detectedlinknumber = llDetectedLinkNumber(0); //llOwnerSay("detectedlinknumber = " + (string) detectedlinknumber); linknum = detectedlinknumber - 1; stext = llList2String(ltext,linknum - 1); //llOwnerSay("linknumber = " + (string)linknum); pos = llList2Vector(positions,(linknum-1)); //llOwnerSay("vector = " + (string)pos); if(pos != ZERO_VECTOR) { if(detectedlinknumber != 1) { //llOwnerSay((string)pos); osTeleportAgent(user,region,pos,lookat); llSetLinkPrimitiveParamsFast(detectedlinknumber,[PRIM_COLOR,ALL_SIDES,<1.0,1.0,1.0>,0.0, PRIM_SIZE,<0.01,0.01,0.01>, PRIM_TEXT,stext,<1.0,1.0,1.0>,1.0]); } } //else //{ //llOwnerSay("not on the list"); //} } timer() { ++seconds; if(seconds == interval) { llResetScript(); } } }
  2. Hi again! I'm trying to make a teleporter script that is supposed to have the following functions (see my script attempts below): 1. The teleporter system consists of buttons (childprims) on a root prim console, as a kind of 'keyboard'. 2. When a button is clicked, that button is supposed to be no more active for a limited time, so that the user teleported to that location cannot be disturbed by others at the same time. 3. The only make-shift solution I have been able to come up with so far has been to turn the button alpha for a time, so that it can no longer be seen, which isn't really sufficient, though. Can you think of a way to make a teleport button clicked unclickable for a certain time? (Besides, I would also be interested in how to write the teleporting destination onto the buttons, so the user knows where he/she is going. llSetText hasn't been possible for me in that script.) Thank you very much in advance! string region; key user; string nameuser; integer linknum; list destinations = [<975.00,29.00,24.00>,"destination1", <861.00,105.00,24.00>,"destination2", <842.00,118.00,24.00>,"destination3", <676,17.00,24.00>,"destination4", <1000.00,417.00,24.00>,"destination5", <717.00,652.00,24.00>,"destination5", <963.00,682.00,24.00>,"destination6", <807.00,677.00,24.00>,"destination7"];//List with teleport destinations. list positions; vector pos; vector lookat = <0.0,0.0,0.0>; integer listlength; integer linkstotal; integer seconds; integer interval = 180;//After this interval the script is reset and the buttons become visible again. default { state_entry() { llSetTimerEvent(1.0); llSetLinkPrimitiveParamsFast(linkstotal,[PRIM_COLOR,ALL_SIDES,<1.0,1.0,1.0>,0.0]);//First all buttons are invisible ... region = llGetRegionName(); positions = llList2ListStrided(destinations,0,-1,2);//The lists contains the names of the destinations after each vector. Hence, only every second entry can be used as a position vector. integer listlength = llGetListLength(positions); //llOwnerSay("listlength = " + (string)listlength); linkstotal = llGetNumberOfPrims(); //llOwnerSay("linkstotal =" + (string)linkstotal); integer i; for(i=1; i<=listlength+1; ++i) llSetLinkPrimitiveParamsFast(i,[PRIM_COLOR,ALL_SIDES,<1.0,1.0,1.0>,1.0]);//... The buttons with a destination vector from the list become visible. } touch_start(integer num) { user = llDetectedKey(0); nameuser = llDetectedName(0); integer detectedlinknumber = llDetectedLinkNumber(0); //llOwnerSay("detectedlinknumber = " + (string) detectedlinknumber); linknum = detectedlinknumber - 1;//The rootprim (number 1) is not supposed to be a button and is excluded. //llOwnerSay("linknumber = " + (string)linknum); pos = llList2Vector(positions,(linknum-1));//The button clicked gets its corresponding destination vector from the list with destination, the first entry being at 0 and hence 'linknumber - 1'. //llOwnerSay("vector = " + (string)pos); if(pos != ZERO_VECTOR) { //llOwnerSay((string)pos); osTeleportAgent(user,region,pos,lookat);//OpenSim version, basically the same as SL. llSetLinkPrimitiveParamsFast(detectedlinknumber,[PRIM_COLOR,ALL_SIDES,<1.0,1.0,1.0>,0.0]); } //else //{ //llOwnerSay("not on the list"); //} } timer() { ++seconds; if(seconds == interval) { llResetScript(); } } }
  3. Thank you very much for your help!๐Ÿ˜ƒ This seems to have done the trick. Yes, in the original script, the second click redefines "rotstart" as the new rotation and so the original start rotation is lost. I would have looked for ever without finding the mistake. So thank you very much, once again. Should I run into more problems, I'll come back again.๐Ÿ™‚
  4. Hi! I've got a script for a memory game. Once clicked, the card is turned over, remains like this for some time (5 seconds countdown), and then is turned over again. (The card then looks for its counterpart using a sensor, which I'm leaving out here for clarity.) In order to keep players from clicking blindly on all cards, I've added an interruption: When a card is clicked twice within the countdown, the seconds are reset to zero, so the player first has to wait through the entire countdown before being able to click again. Unfortunately, when the card is clicked twice, the seconds are properly reset, but the card then is not turned over after the countdown. Maybe you can find the mistake? I'm posting the script below. Thank you very much in advance! integer countdown = 5; key player; integer seconds; vector rotnew = <0.0,180.0,0.0>*DEG_TO_RAD; rotation rotstart; integer on; default { touch_start(integer num) { rotstart = llGetRot(); if(on == FALSE) { llSetTimerEvent(1.0); llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_ROTATION,llEuler2Rot(rotnew)]);//The card is turned over. on = TRUE; } else { seconds = 0;//After clicking the card a second time, the countdown is reset to zero again. llRegionSayTo(player,0,"Please wait for " + (string)countdown + " seconds."); } } timer() { ++seconds; llOwnerSay((string)seconds); if(seconds == countdown)//The countdown has run out ... { llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_ROTATION,rotstart]);//... the card is turned back over again. llResetScript(); } } }
  5. I might have found the mistake myself: The position of the childprim must be substracted from the position of the root prim, apparently: integer inum; integer seconds; vector startpos; vector newpos; integer on; default { touch_start(integer num) { inum = llDetectedLinkNumber(0); llOwnerSay("number is : " + (string)inum); if(inum == 2) { startpos = llList2Vector(llGetLinkPrimitiveParams(2,[PRIM_POS_LOCAL]),0); llOwnerSay("startpos:" +(string)startpos); on = TRUE; llOwnerSay("is on"); } if(inum == 1) { if(on == TRUE) { llSetTimerEvent(1.0); llOwnerSay((string)inum); newpos = llList2Vector(llGetLinkPrimitiveParams(LINK_ROOT,[PRIM_POS_LOCAL]),0); llOwnerSay("newpos: " +(string)newpos); llSetLinkPrimitiveParamsFast(2,[PRIM_POS_LOCAL,newpos - llGetPos() + <0,0,1> ]); } else { llOwnerSay("not on"); } } } timer() { ++seconds; if(seconds == 5) { llSetLinkPrimitiveParamsFast(2,[PRIM_POS_LOCAL,startpos ]); } if(seconds == 7) { llResetScript(); } } }
  6. Hi! I would like a childprim in a linkset consisting of one root and one childprim to do the following: When the childprim is touched AND the rootprim is touched after this, the childprim is supposed to move onto the position of the root prim (slightly above it), stay there for some time and move back to its initial position again. In my script, however, the childprim, instead of taking on the same position as the rootprim, moves further away from the rootprim and in the end even further again, instead of returning to its initial position. I don't find the mistake. It seems to have to do with llSetLinkPrimitiveParamsFast using a wrong position. Do you maybe see the mistake? I'm posting the script below. Thank you very much in advance! integer inum; integer seconds; vector startpos; vector newpos; integer on; default { touch_start(integer num) { inum = llDetectedLinkNumber(0); llOwnerSay("number is : " + (string)inum); if(inum == 2) { startpos = llList2Vector(llGetLinkPrimitiveParams(2,[PRIM_POSITION]),0); llOwnerSay("startpos:" +(string)startpos); on = TRUE; llOwnerSay("is on"); } if(inum == 1) { if(on == TRUE) { llSetTimerEvent(1.0); llOwnerSay((string)inum); newpos = llList2Vector(llGetLinkPrimitiveParams(LINK_ROOT,[PRIM_POSITION]),0); llOwnerSay("newpos: " +(string)newpos); llSetLinkPrimitiveParamsFast(2,[PRIM_POSITION,newpos + <0,0,1>]); } else { llOwnerSay("not on"); } } } timer() { ++seconds; if(seconds == 5) { llSetLinkPrimitiveParamsFast(2,[PRIM_POSITION,startpos]); } if(seconds == 7) { llResetScript(); } } }
  7. Thank you very much, Qie Niangao. So, using the same position as the root prim's for the child prim automatically creates an offset for the child prim's position? Your advice seems to have done the trick. I'm posting the script below. Should I run into more problems, I'll come back again. Thank you all for your help very much again! ๐Ÿ™‚ default { state_entry() { vector startpos = llGetRootPosition();//Position of the rootprim llOwnerSay("startpos = " + (string)startpos); llSetLinkPrimitiveParamsFast(LINK_ALL_CHILDREN,[PRIM_POSITION,<0,0,1>]);//Position of the childprim +1 meter offset in z-direction vector newpos = llList2Vector(llGetLinkPrimitiveParams(2,[PRIM_POSITION]),0); llOwnerSay("newpos = " + (string)newpos); } }
  8. Thank you very much for your idea. I've further simplified the script to avoid errors. The position of the childprim is now supposed ot be the same as the root prim's. Unfortunately it didn't help. (Renaming LINK_ALL_CHILDREN to link number "2" also didn't make any difference.) I tried some debugging and had a really bizarre result using the script below. The newly created vector of the linked prim ("newpos") produced the following result: [12:21] Primitive: startpos = <380.697083, 77.889473, 21.167229> [12:21] Primitive: newpos = <391.888062, 80.507759, 21.724491> I really don't get it. default { state_entry() { vector startpos = llGetRootPosition();//Position of the rootprim llOwnerSay("startpos = " + (string)startpos); llSetLinkPrimitiveParamsFast(2,[PRIM_POSITION,startpos]);//Position of the childprim vector newpos = llList2Vector(llGetLinkPrimitiveParams(2,[PRIM_POSITION]),0); llOwnerSay("newpos = " + (string)newpos); } }
  9. Thank you for your quick reply. I just don't understand why, but it doesn't seem to make any difference (that's what I meant with "PRIM_POS" in my original post, I really meant to write "PRIM_POS_LOCAL". It leads to the same result. The script seems to be logical that way. I really can't see where the mistake is. Any other ideas will be appreciated.
  10. Hi! I would like to automatically set the position of a childprim on the same position as the root prim, but 1 meter above the root prim. This really should not be a problem, but for whatever reason, I cannot accomplish this. The childprim always ends up several meters set away from the root prim in the x-position. (The same also happens when I replace PRIM_POSITION with PRIM_POS.) I can't figure out what is wrong. Maybe you can find the mistake? Thank you very much in advance! Here is my script: vector startpos; default { state_entry() { startpos = llGetPos();//Position of the rootprim llOwnerSay("startpos = " + (string)startpos); llSetLinkPrimitiveParamsFast(LINK_ALL_CHILDREN,[PRIM_POSITION,startpos - <0.0,0.0,1.0>]);//Position of the childprim } }
  11. Thank you so much, for your quick replies! Making the counter a global variable did the trick. I could have kept looking for hours without finding the solution. I learned a lot today. Thanks again! ๐Ÿ™‚
  12. Hi! I'm trying to build a linked prim which does the following: The linked prims are invisible, except for the root prim. There is a timer, once per second. Every second, one more childprim is supposed to become visible, i.e. first prim 2, then also 3, then also 4 etc., until all childprims are visible. I have a script that does this in one go (see below). However, I would like the childprims to become visible in a sequence, i.e. one more every second. I'm not even sure if this is possible. But maybe you have an idea. I'm posting my script below. Thank you very much in advance! default { state_entry() { llSetLinkPrimitiveParamsFast(LINK_ALL_OTHERS,[PRIM_COLOR,ALL_SIDES,<1.0,1.0,1.0>,0.0]); } touch_start(integer num) { llSetTimerEvent(1.0); } timer() { integer i; do llSetLinkPrimitiveParamsFast(i+1,[PRIM_COLOR,ALL_SIDES,<1.0,1.0,1.0>,1.0]);//i+1 to exclude the root prim. while(++i <5); } }
  13. Update: I've found the solution myself now. I forgot that the position from which the pieces are scattered out is not the start position of the particular piece, but the center of the puzzle "gamepos". So the updated version looks as follows now: float circle_radius = 5.0; float circle_height = -0.5; float position_angle = llFrand(TWO_PI); vector piece_position = gamepos + <circle_radius,0,circle_height> * llEuler2Rot(<0,0,position_angle>); float rotation_angle = llFrand(TWO_PI); rotation piece_rotation = llEuler2Rot(<0,0,rotation_angle>); llSetLinkPrimitiveParamsFast(0, [ PRIM_POSITION, piece_position, PRIM_ROTATION, piece_rotation ]); Just one more thing: As you can see, in the screenshot below, the pieces are in some cases put in the same positions. In case you know a simple way of avoiding that and giving each piece its unique position, I would be very grateful. ๐Ÿ™‚
  14. Thank you very much for your help! It's improved the situation significantly. To give one clarification first of all, the puzzle pieces are not linked to the puzzle root prim. Each piece is an unlinked prim and has the particular script in its inventory. This even simplifies the situation a bit, I think. However, it seems to make it harder to arrange the pieces in such a beautiful perfect circular shape, as in your screenshot. In my version, the pieces now really scatter randomly within the radius. This not a big problem since it already fulfills the requirements of the random position of the pieces and it is possible to play the game. Still, your screenshot looks really nice. ๐Ÿ™‚ If it would be possible to arrange the pieces in such a way, this would be amazing. Do you maybe see a simple way of how to achieve a perfect circular shape in the unlinked pieces version? Here is my version for the unlinked puzzle pieces: vector vstartpos = llGetPos(); float circle_radius = 5.0; float circle_height = -0.5; float position_angle = llFrand(TWO_PI); vector piece_position = vstartpos + <circle_radius,0,circle_height> * llEuler2Rot(<0,0,position_angle>); float rotation_angle = llFrand(TWO_PI); rotation piece_rotation = llEuler2Rot(<0,0,rotation_angle>); llSetLinkPrimitiveParamsFast(0, [ PRIM_POSITION, piece_position, PRIM_ROTATION, piece_rotation ]);
  15. Thank you very much for your suggestions. I've tested both and they both work. The method using llRot2Fwd worked better than my original one, but still caused the division into to opposite piles. The other method, using a list containing the prim positions works more exactly. For whatever reason, it keeps placing some puzzle pieces in the exact same position as another piece, although none of the positions on the list are equal. Can you maybe see why this is the case? Thank you very much for your help anyway! ๐Ÿ™‚ list lpos=[ <0.0,5.0,0.1>,<1.0,5.0,0.1>,<2.0,5.0,0.1>,<3.0,5.0,0.1>, <1.0,4.0,0.1>,<2.0,4.0,0.1>,<3.0,4.0,0.1>, <5.0,0.0,0.1>,<5.0,1.0,0.1>,<5.0,2.0,0.1>,<5.0,3.0,0.1>, <-5.0,0.0,0.1>,<-5.0,1.0,0.1>,<-5.0,2.0,0.1>,<-5.0,3.0,0.1>, <1.0,-4.0,0.1>,<2.0,-4.0,0.1>,<3.0,-4.0,0.1>, <-1.0,5.0,0.1>,<-2.0,5.0,0.1>,<-3.0,5.0,0.1>, <0.0,-5.0,0.1>,<-1.0,-5.0,0.1>,<-2.0,-5.0,0.1>,<-3.0,-5.0,0.1> ];//The puzzle has 25 pieces, numbered 0 - 24; list lrandpos; bounce(){ lrandpos = llListRandomize(lpos,1); string sstride = llDeleteSubString(llGetObjectName(),0,10);//The pieces have the name puzzlePiece0 - puzzlePiece24 integer istride = (integer)sstride; vector vrand = llList2Vector(lrandpos,istride);//Each piece is given the position at the index with the same number as the object name. llSetLinkPrimitiveParamsFast(0,[PRIM_POSITION, (gamepos + vrand)]);//gamepos is the position of the puzzle game center. float frotangZ = llFrand(360.0); vector rotationAngle = <0.0, 0.0, frotangZ>; rotation rot = llEuler2Rot( rotationAngle ); llSetLinkPrimitiveParamsFast(0,[PRIM_ROTATION, rot]); }
  16. Hi! I've got a script of a jiggsaw puzzle. Before the puzzle can be played, the pieces are spread around from their initial position, which is the complete puzzle image. - They are supposed to be spread in a random fashion, so that the pieces are being mixed. - They are also supposed to be spread within a certain radius, so that all pieces always remain in the sight of the person playing. - The puzzle is then supposed to be assembled in the initial position again, which is in the center of the circle. The script I've come up with so far arranges the pieces in two loose piles on opposite ends. The ideal way of spreading the pieces, though, would be in a rough, random 'circle'-like shape around their initial position. If you could help me out with this, I would be very grateful. Below you can find the part of the script spreading the pieces. (Each piece contains this script.) Thank you very much in advance! vector gamepos = <...>;//initial position of the complete puzzle integer random_integer( integer min, integer max ) { return min + (integer)( llFrand( max - min + 1 ) ); } bounce()//The pieces are being spread / scattered. { integer irandom; integer positive_negative = random_integer(0,1); if(positive_negative == 0) { irandom = 1;//This creates pile 1 } else { irandom = -1;//... pile 2 } float randX= llFrand(7.0);//This is the x-value of the spreading distance float randY= llFrand(7.0);//... y-value ... vector vscatter = gamepos + <irandom*(randX),irandom*(randY),0.5>; llSetLinkPrimitiveParamsFast(0,[PRIM_POS_LOCAL,vscatter]); }
  17. Thank you, Mollymews! I'd made the same experience before, but couldn't make any sense of it. This explains it now, I guess. Thank you very much for taking your time and giving this helpful tip!๐Ÿ™‚๐Ÿ‘
  18. Hi again, and a Happy New Year to everyone, first of all!๐Ÿ˜Ž๐Ÿพ๐Ÿฅ‚ After experimenting a bit more, I've made an observation that I can't really make any sense of: The problem with the timer described above went away when I arranged the timer and listener event in the same order as the llSetTimer and llListen commands before (s. script excerpt below). I can't quite understand why the order of the events in the script should make any difference. Do you maybe have an idea? Thank you! ... default { touch_start (integer num) { llSetTimerEvent(1.0); //first: llSetTimerEvent gListen=llListen(CHANNEL, "", NULL_KEY, ""); //second: llListen } timer() //timer-event: First again { ++seconds; ttime = time-seconds; llSetText("time left (in seconds): "+(string)ttime, <1.0, 1.0, 1.0>, 1.0); } listen(integer channel, string name, key id, string message) //listen-event: Second again { //in this order, the timer works } }
  19. Thank you very much for your quick and detailed reply!โ˜บ๏ธ I wouldn't have come up with these ideas on my own. This explains everything to me at this point. Again, thank you very much.๐Ÿ‘๐Ÿ™‚
  20. Hi! I've got a script that is supposed to play a random sound out of 4 sound files in the inventory of the prim. This means that whenever the script is started, any of the 4 sounds is supposed to be played by a random choice. I've used llFrand to create a "random" choice for this. Here is the part of the script: isound = (integer)llFrand(4.0); llPlaySound(llGetInventoryName(INVENTORY_SOUND,isound),1.0); There are three things I couldn't quite figure out. 1. The float in llFrand is in the range between 0 and the maximum number (given in the brackets). Is the first sound in llFrand counted as "0" or "1"? That is, if I have 4 sounds, do I define the range of the float in the brackets as "3" (the first sound counted as "0") or "4" (the first sound counted as "1")? 2. In order to play the sound, the float must be typecast into an integer. I'm not quite sure if I used the correct way of doing it. I've simply converted the float by adding "(integer)" in front of it. Is the part following the "." in the float simply omitted? For example, would the float created by llFrand "0.2" simply be reduced to "0" ("1.3" be reduced to "1" etc.)? It doesn't really look legitimate because this would be changing the value of the float quite a bit. 3. If I only want to play the sound files 2-4 and NOT soundfile 1 at this point, how do I adjust llFrand? Can llFrand also have a different range than between 0 and maximum? (for example in the range from 2-4 WITHOUT 1). Is that possible? Thank you very much in advance!
  21. //https://community.secondlife.com/forums/topic/444235-quiz-using-dialog-menu/ integer gListen; integer time = 180; integer ttime; integer seconds; integer points; key player; string nameplayer; integer gameover; integer CHANNEL = -886; integer index; string answer; integer channelgerman = -1291; string quizname; integer iAnswered; 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"]; list quiz = [ // question answer picks (buttons) the pipe| is the delimiter "\n \nWhat is 1 + 1?\n \n \n \n \n", "2", "1|2|3|4", "\n \nWhat is 1 + 2?\n \n \n \n \n", "3", "1|2|3|4" ]; integer stride = 3; integer quiz_length; integer question_number; string correct_answer; // so it's available in the listen event when the user has made their choice integer on; default { state_entry () { quizname = llGetObjectName(); llSetText("Click to start.", <1.0, 1.0, 1.0>, 1.0); quiz = llListRandomize (quiz, stride); quiz_length = llGetListLength (quiz); llSetClickAction(CLICK_ACTION_TOUCH); } touch_start (integer num) { if(!on) { on = TRUE; player = llDetectedKey(0); nameplayer = llDetectedName(0); //nameplayer = llKey2Name(player); gListen=llListen(CHANNEL, "", NULL_KEY, ""); // listen for dialog answers (from multiple users) llSetClickAction(8); llSetTimerEvent(1.0); string question = llList2String (quiz, question_number * stride); correct_answer = llList2String (quiz, question_number * stride + 1); list choices = llParseString2List (llList2String (quiz, question_number * stride + 2), ["|"], []); llDialog (player, question, choices, CHANNEL); ++question_number; } } timer() { ++seconds; ttime=time-seconds; llOwnerSay((string)seconds); llSetText("time left (in seconds): "+(string)ttime, <1.0, 1.0, 1.0>, 1.0); if(ttime == 0) { llSay(0, "\n \nTime is up!\n \n \n"); llResetScript(); } if(seconds %5 ==0) { if(iAnswered == TRUE) { iAnswered = FALSE; string question = llList2String (quiz, question_number * stride); correct_answer = llList2String (quiz, question_number * stride + 1); list choices = llParseString2List (llList2String (quiz, question_number * stride + 2), ["|"], []); llDialog (player, question, choices, CHANNEL); ++question_number; } } } listen(integer channel, string name, key id, string message) { if (message == correct_answer) { ++points; llPlaySound("ed124764-705d-d497-167a-182cd9fa2e6c",1.0); llSay(0, "\n \n \nCorrect, " + nameplayer + "!" + "\n \n \n"); llSay(0, "Punkte: " + (string)points + " / " + quiz_length/3 + "\n \n \n \n"); if (question_number * stride == quiz_length) { llListenRemove(gListen); //llDialog( id, "\n \nCongratulations, " + nameplayer + "!\n \n \nYou have won!", ["OK"], CHANNEL); This seems to have caused the problem. llPlaySound("ed124764-705d-d497-167a-182cd9fa2e6c",1.0); llRegionSay(channelgerman,"task " + quizname + ":" + " " + nameplayer); llResetScript(); } else { iAnswered = TRUE; } } else { llSetText("time left (in seconds): " + (string)ttime, <1.0, 1.0, 1.0>, 1.0); llSay(0, "\n \nwrong. \n \nYou have lost, "+nameplayer+".\n \nStart again.\n \n \n"); integer iWhichOne = (integer) llFrand( llGetListLength( lSounds ) ); llPlaySound(llList2String(lSounds, iWhichOne), 1.0); llResetScript(); } } } Hi again! I tried to implement your suggestions. (I hope I got it right?) Anyway, the script seems to work now. The problem SEEMS to have been the line at the end of the quiz: llDialog( id, "\n \nCongratulations, " + nameplayer + "!\n \n \nYou have won!", ["OK"], CHANNEL); I GUESS the problem was that the script was reset with this dialog still being open, resulting in some unfinished process hanging in the air(?). That is the only answer I could come up with. At least the script seems to work now. I'm still open for suggestions, should I still have left some flaws in the script. Thank you very much for your support everyone!๐Ÿ™‚
  22. Thank you very much for your ideas. Theyโ€˜re awesome.๐Ÿ˜Š Iโ€˜ll try them out in the next days when I have some time. @Qie Niangao: Hm, I suspected that, too. But the original script is exactly the way I posted it here. Maybe my region is contributing to the problem. Sometimes scripts donโ€˜t fully function there that work in other regions (OpenSim). Iโ€˜ll try out Roligโ€˜s suggestion using llOwnerSay, which I havenโ€˜t done, yet. Maybe Iโ€˜ll find out more this way. Iโ€˜ll come back and let you know then. Thank you very much for your help, again!
  23. Thank you very much for your advice. This all sounds really interesting. ๐Ÿ™‚ The llSleep actually is what I was trying to replace by using the timer. The script had quite a long processing time span in the "top scripts" list when using llSleep. Replacing llSleep seems to have reduced that processing time quite a bit. I've read that llSleep blocks one entire thread of the SIM engine for as long as it is active. Since I would like to use many of these quiz scripts in my region, I figured, to prevent lag, it might make sense to get rid of as many llSleep commands as possible. I'm not sure if that makes sense. What do you think?
  24. Hi! I've got a script of a multiple choice quiz. The quiz asks the player questions using a dialog. The player only has a certain time to finish the quiz, otherwise the script is reset. The script works so far. Now the problem: The timer does not work. (It works in the first round, but, strangely, not the following rounds afterwards.) I assume the timer event is replaced by the listen event, and hence, it stops working. Is that the cause of the problem? (But then again, why does it work in the first round? Plus, when I cut the script significantly shorter, the timer is still working, in spite of the listen event.) Can you maybe think of an alternative solution? Here is the script: //https://community.secondlife.com/forums/topic/444235-quiz-using-dialog-menu/ integer gListen; integer time = 180;//The playing time in seconds; afterwards, the script is restarted. integer ttime; integer seconds; integer points; key player; string nameplayer; integer gameover; integer CHANNEL = -886;//Channel-number of the dialog integer index; string answer; integer channelgerman = -1291; integer channelenglish = -1292; integer channelmaths = -1293; integer channelscience = -1294; integer channelsocialscience = -1295; integer channelreligion = -1296; integer channelart = -1297; integer channelmusic = -1298; string quizname; 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"]; list quiz = [ // question answer picks (buttons) the pipe| is the delimiter "\n \nHow much is 1+1?\n \n \n \n \n", "2", "1|2|3|4", "\n \nWhich is the first letter in the alphabet?\n \n \n \n \n1. A\n \n2. B\n \n3. C\n \n4. D\n \n \n", "1.", "2.|3.|4.|1." ]; integer stride = 3; integer quiz_length; integer question_number; string correct_answer; // so it's available in the listen event when the user has made their choice integer on; default { state_entry () { quizname = llGetObjectName(); llSetText("Click here to start the quiz.", <1.0, 1.0, 1.0>, 1.0); quiz = llListRandomize (quiz, stride); quiz_length = llGetListLength (quiz); llSetClickAction(CLICK_ACTION_TOUCH); } touch_start (integer num) { if(!on) { on = TRUE; player = llDetectedKey(0); nameplayer = llDetectedName(0); gListen=llListen(CHANNEL, "", NULL_KEY, ""); // listen for dialog answers (from multiple users) llRegionSayTo(player,0,"\n \nHello,\n \n"+ nameplayer + "!\n \n \nClick on the replies in the dialog at the top right.\n \n \n"); llSetClickAction(8); llSetTimerEvent(1.0); string question = llList2String (quiz, question_number * stride); correct_answer = llList2String (quiz, question_number * stride + 1); list choices = llParseString2List (llList2String (quiz, question_number * stride + 2), ["|"], []); llDialog (player, question, choices, CHANNEL); ++question_number; } } timer() { ++seconds;//This is the part that does not work. ttime=time-seconds; llSetText("playing time left (in seconds): "+(string)ttime, <1.0, 1.0, 1.0>, 1.0); if(ttime == 0) { llSay(0, "\n \nYour time is up!\n \n \n"); llResetScript(); } } listen(integer channel, string name, key id, string message) { if (message == correct_answer) { ++points; llPlaySound("ed124764-705d-d497-167a-182cd9fa2e6c ",1.0); //llPlaySound(llGetInventoryName(INVENTORY_SOUND,1),1); llSay(0, "\n \n \nThat is correct, " + nameplayer + "!" + "\n \n \n"); llSay(0, "points: " + points + " / " + quiz_length/3 + "\n \n \n \n"); if (question_number * stride == quiz_length) { llListenRemove(gListen); llDialog( id, "\n \nCongratulations, " + nameplayer + "!\n \n \nYou have won!", ["OK"], CHANNEL); llPlaySound("ed124764-705d-d497-167a-182cd9fa2e6c",1.0); llResetScript(); } else { llSensorRepeat( "q", "", AGENT , 0.01, 0.01, 1.0);//The llSensorRepeat is used as an additional timer here. This way, there is a one-second-pause between the dialog-questions popping up, making the quiz less hectic. } } else { llSay(0, "\n \nThat is wrong. \n \nYou have lost, "+nameplayer+".\n \nStart the quiz again.\n \n \n"); integer iWhichOne = (integer) llFrand( llGetListLength( lSounds ) ); llPlaySound(llList2String(lSounds, iWhichOne), 1.0); llResetScript(); } } no_sensor() { llSensorRemove(); string question = llList2String (quiz, question_number * stride); correct_answer = llList2String (quiz, question_number * stride + 1); list choices = llParseString2List (llList2String (quiz, question_number * stride + 2), ["|"], []); llDialog (player, question, choices, CHANNEL); ++question_number; } }
  25. Wow, so many replies in such a short time. This helps me a lot, thank you very much. I'm still struggling to understand some of the details, but I'll just try to remember.๐Ÿ˜‰ Thank you very much for your help, once again!
×
×
  • Create New...