You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

DVD random trivia game

Alright, so this is very specific, but will hopefully be useful to others as well

I am creating a trivia game on a DVD

-each question is a menu item with the ability to select 1 of 4 answers (a,b,c,d)

-if the answer is wrong, it plays a 'Wrong' video track. I need this to loop back to the menu that played previous to it. (i.e., I'm on question 8, I get it wrong, it will play the 'wrong' video track then I need it to go back to question 8.)

-if the answer is correct, it plays a 'correct' video track, then has to move on to another question, one that hasn't played before. (so I get question 8 right, it plays the 'correct' video track, then needs to select another question that is not 8, or any other one I have already played)

If it is too much to make it a non-repetitive random play, then I'd be fine with a repetive random play.

Any help is greatly appreciated!

Posted on Aug 4, 2005 8:50 PM

Reply
18 replies

Aug 5, 2005 2:44 AM in response to Barron Crawford

Take a look on the DVD Studio Pro Scripting tutorials here:

http://www.dvdcreation.com/articles/listarticle.jsp?type=tutorials-171-20-20

http://www.dvdcreation.com/articles/viewarticle.jsp?id=29302

DVD Studio Pro Scripting, Series 1
Part 1: General scripting information
Part 2: Creating an interactive quiz
Part 3: Keeping track of time
Part 4: Pausing and resuming a timer

Aug 5, 2005 4:00 AM in response to Barron Crawford

Hi Barron - welcome.

If I understand you correctly you want the questions to be random, which means randomly accessing menus. Occasionally you could get the same menu twice, so if possible you want to avoid that. When a question is correct you want to play a particular track, then generate a new question. When it is wrong you want to play a different track and then repeat the last question.

OK - this is all possible, but some of it can get quite intense - particularly if you want to track which questions have been shown already. You might also want to keep a running score - or at least a grand total score when done.

Have you done any scripting before? I see that you are using DVDSP4, which is good, as it will help simplify some of the more advanced stuff if you really get into this.

Firstly, to generate a random number use a script like this (assuming five menus, or sets of questions):

ran GPRM0, 65535
mod GPRM0, 5
Jump menu1::Button1 If (GPRM0 = 1)
Jump menu2::Button1 If (GPRM0 = 2)
Jump menu3::Button1 If (GPRM0 = 3)
Jump menu4::Button1 If (GPRM0 = 4)
Jump menu5::Button1 If (GPRM0 = 5)

Place a small prescript on each menu to give it an identifier:

mov GPRM1, 1
Exit pre-script

(Change the value to be different for each menu)

Now, you need to set each button on the menu to go to the 'wrong answer' track except the correct button. This will need to go to a script which adds a value to keep score:

add GPRM2, 1
Jump Correct Track

The correct track will then end jump back to your random menu generator. The Wrong answer track will end jump to short script:

Jump Menu1::Button1 If (GPRM1 = 1)
Jump Menu2::Button1 If (GPRM1 = 2)
Jump Menu3::Button1 If (GPRM1 = 3)
Jump Menu4::Button1 If (GPRM1 = 4)
Jump Menu5::Button1 If (GPRM1 = 5)

Now the scoring...

At some point you need to have an end to this. You could, for example, have a button on the question menus which reads 'get your current score' and simply links to another short script. This will send you on to a series of menus (or better still a series of images in a track, set up as stories) which hold all the possible score values. remember, you cannot dynamically create anything on a DVD.

Each 'check score' button would go to this:

Jump Track 3::Story1 If(GPRM2 = 1)
Jump Track 3::Story2 If(GPRM2 = 2)
Jump Track 3::Story3 If(GPRM2 = 3)
Jump Track 3::Story4 If(GPRM2 = 4)
Jump Track 3::Story5 If(GPRM2 = 5)

However - you cannot keep on going over and over the questions indefinitely, since you will run out of menus and space to hold the answer cards. You need to build in a check to see how many questions have been answered, or if all of the questions have been answered. You can do this in a number of ways as well, for example, every time a random number is generated you could add a value to a GPRM and track it so that only five random numbers get made. You would then need to alter the random script a bit:

add GPRM4, 1
goto 10 If(GPRM4 >= 6)
ran GPRM0, 65535
mod GPRM0, 5
Jump menu1::Button1 If (GPRM0 = 1)
Jump menu2::Button1 If (GPRM0 = 2)
Jump menu3::Button1 If (GPRM0 = 3)
Jump menu4::Button1 If (GPRM0 = 4)
Jump menu5::Button1 If (GPRM0 = 5)
Jump Finished

Where 'Finished' could be a menu or track that you have made. This way, every time a user picks a question a count is made and stored in GPRM4. If they go back to an old question nothing gets added to that count and so they can repeat the ones they get wrong as many times as they like. However, if they get it right and go on to a new question they will add to the count and when they get to the random script it will move them straight to the finishing post after 5 questions have been answered (i.e. the sixth attempt at a new question won't take place).

cont..

Aug 5, 2005 4:02 AM in response to Hal MacLean

..cont.

This won't track which questions have been asked, will limit the number of questions available, provides a scoring system and gives an out point after five questions. You can change any of that to larger numbers as you wish.

If you want a true random system then we have to explore tracking which menus have played and looking only for those that haven't. Fortunately with DVDSP4 you have GPRM partitioning which will help greatly here - avoiding bitshifting techniques and bit based maths. It is all possible - just intricate!

Good luck, hope this gets you on the right road.

Aug 6, 2005 10:56 AM in response to Barron Crawford

Are you seeing the odd behaviour in simulator, or are you building this to your hard drive and using DVD Player, or have you burnt a disc and are seeing it on your set top player?

I can't see why it won't pick Q3, for example - but then that's the nature of random choice, I guess! What we can do is build in a check to see if the question has been asked and then make it ask a different one if it has. This is a little bit more scripting, but not a great hassle with DVDSP4. All you would do is partition a GPRM into as many pieces as you need, then each time a menu is selected add a value into the corresponding partition. Then, when the next choice is made it looks to see if the value is present (i.e. the question has already been asked) - if so it moves to a different question, if not it puts the value in place and displays that question.

As I said, intricate, a few more scripts, but not impossible!

Aug 6, 2005 11:55 AM in response to Barron Crawford

I just built it and used DVD player and got the same results

These are some of the trials (with 5 questions so far).

1 1 2 1 4 cut out

1 4 4 3 cut out

1 2 3 1 2 2 1 1 cut out

1 3 4 cut out

I've never got a question 5 yet, but thhat likely does have something to do with the random selection becuase I've finally gotten some 3's.

Aug 6, 2005 1:00 PM in response to Barron Crawford

What concerns me is that you are not getting five questions before a quit every time - assuming you are answering them correctly, that is. If you get them wrong then you should get a chance to repeat the q without adding to the counter.

I'll try and set up a mini project to see what needs to happen, then I'll post it for you to see.

As for not getting a 5, try changing the 'mod' value to '6'.

Aug 6, 2005 1:37 PM in response to Hal MacLean

So I tried that and it didn't help,

however I got rid of the mod all together, and simply made the random selection between 1-5. That seemed to solve the problem of random quits and also allowed all the questions to be asked (though your right, I can't figure out why that wasn't already happening)

was the mod command neccessary if I want to make it non-random?

I'm also looking into this non-random thing and have been trying to do it with bit-wise math, but have no idea how this can be done.

Aug 6, 2005 3:21 PM in response to Barron Crawford

Sorry Barron - my mistake. You need to alter the jump scripts a little, since the mod command will return a value from zero to four - i.e. five values, but starting at zero. In the scripts I wrote out here I began the jump statements from 1. My bad.

The mod command is important since it completes the random number generation and matches the number of questions that you have. If you don't want this randomised then it isn't necessary at all.

I have now set up a simple project for you to look at. It definitely only allows me to do five questions, but the randomiser will repeat - I haven't yet written the scripts to track what has already played. You can get it from my .mac space:

http://homepage.mac.com/halgernon

You are looking for a .zip file named 'quiz.zip'. In there is a disc image and the project file (in PAL format) which I used. The way it works is that if the user gets the answer wrong they return to the same question. If they get it right they get a chance at a new question. After five questions the end is reached, but they can choose to try again. You will see that I have re-named the GPRMs to show what I was doing, and you may notice one unused one is named for scoring - but like you I took it out... I couldn't decide if the user should score when they get it wrong then repeat it and get it right. That's something for you to decide, I think!

True random will require bit-wise maths, or GPRM partitioning. Essentially, what you do is move a value into a partition each time a question is asked. before a new question gets displayed, you first check to see if it has already been asked (i.e. check to see if the value is in place). If it is, you can either generate another random number, or simply subtract 1 from what you had and check that slot.

The more questions in the quiz the more likely it is that you'll not get repeats. Three to five questions will show repeats, almost certainly, but 80 or more will make it unlikely.

Aug 7, 2005 7:19 AM in response to Hal MacLean

And just for good measure I have re-written the quiz to be non-repeating. It will randomly select a question from the five, check to see if it has already asked it and if so choose another... otherwise it will show the question.

I have done this in a very simplistic way, using repeating sections of code. If I were to be doing this with hundreds of questions I would want to re-think it to make it more manageable to write - but this should get you on the right track.

I removed the earlier version from the .mac space, replacing it with a 1.3Mb file called 'non-repeating quiz.zip' which you can download and examine from:

http://homepage.mac.com/halgernon

Sep 14, 2005 1:57 PM in response to Hal MacLean

Hey Hal, I've downloaded the non-repeating quiz from your page, and it's pretty amazing. I'm new at DVD SP so my head is spinning right now as I'm learning about scripting!

The thing is, I haven't picked an easy project from which to learn all the basics!

I'm having a trivia game too on my DVD (15 questions with 4 answers), but instead of having just one "correct" and one "incorrect" clip, I have 1 correct and 3 incorrect ones. Also, instead of having the incorrect clip jump back to the original question, I'd like both the correct and incorrect clips to jump to the next question (no scoring at the end.)

Would you let me know about the changes I need to make in the scripting you've previously posted? Like I said, I'm reading all about scripting right now, but I'd really appreciate the heads-up!

Sep 14, 2005 5:07 PM in response to Hal MacLean

That would be great!

I was thinking about having 4 scripts (1 that would jump to the correct clip and 3 that would jump to each of the 3 incorrect clips) and assign them to the corresponding buttons.

What I don't know, is how to make each clip go back to the next question! I'm guessing I'll have to set a script for each track (4 in total) but I don't know what setting to select for the target.

Am I right so far?

DVD random trivia game

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.