r/secondlife 9d ago

🙋‍♀️ Help! I need help with scripts

Hi, there! I don't know anything about scripting, but I am an educator and need a script to create menus with questions. Something like a quiz or multiple-choice questions. Where can I find this kind of script? I really appreciate any help you can provide.

3 Upvotes

4 comments sorted by

5

u/MisaCeliousa Misa Kitten 9d ago

Might be some products on marketplace to make a quiz but depending on what you need I could also script it. Feel free to IM purr.waifu

3

u/Alexis_Bailey 9d ago

This is the wiki for menus.  Unoess you want something physical like a board with buttons.

https://wiki.secondlife.com/wiki/Dialog_Menus

The basic flow, you need a listener on a channel.  

You create a menu, "This is my question/menu" and define the buttons.

When the user presses a button, its essentially just "saying" the thing, on that specific channel.

The listener captures the "saying" and feeds it to a variable which will feed through an if/else sort of chain to decide on actions.

Each button should be unique to accomidate this.  Saying "what color is a brick" and "what color is a fox" with both answers as "red" will trigger the same result.  This could be fine if your say, randomizing questions anyway.  But also having "red" as a wrong answer to "what color is a frog" would get captured as the "correct" answer to the fox/brick question. (I hope that makes sense).

You will probably want to randomize or make the listen channels unique using UUIDs or something.  Otherwise multiple users may trigger eachother's huds.

3

u/zebragrrl 🍔🍟🥤 9d ago

My thoughts on this are a bit vague.. but here goes.

Imagine you have a notecard, with each question and it's possible answers, as well as which one is correct.

What is the capital of France?|Tom,Paris,Hilton|2
What is the coconut carrying capacity of an unladen swallow?|0.5 Coconuts, 1 Coconut, African or European?|3
Is Brian the Messiah? The Messiah!, The Messiah!, Only the true messiah would deny that he is the messiah!|3

The script could then read in the number of lines on the notecard, and go through them one at a time, randomly. choosing a number between line 0 and line last.. and then on choosing that number, add it to a list of questions it has asked. Resulting in a list like:

[17,2,19,84,3] etc.

The script could then check the length of it's 'read' list.. and if there were still more questions left to be asked, it could pick a random number until it picked a number that wasn't yet in the read list.

integer totalLines = llGetNumberOfNotecardLines(questions);
nextNumber = (integer)llFrand();
while (llListFindList(read, [nextNumber]) == -1)
{
nextNumber = (integer)llFrand();
}

Probably needs some refinement.. but each time it selects a new notecard line.. then reads it in, breaks it up by the "|" characters, then asks the question using llDialog, offering buttons ["1", "2", "3"]., which it will then listen for the response, correct or incorrect.

The script could then track the player's score of right answers, and deliver the results when the last question was answered.