Is Recording Simple Responses Possible?

I want to save a player’s responses to questions so that when the process is finished, he/she can see how he/she responded. The project would be in seven sections with each section having 10 questions with the question and choices (buttons) on screen.

A Is this possible?
B Is it difficult?
C Anyone know of a good tutorial for this type of project

Thanks [import]uid: 45029 topic_id: 10277 reply_id: 310277[/import]

Hey there :slight_smile:

A) Yes

B) That depends on the person, but I’d say it’s not too challenging.

As to tutorials - no.

If you want to genuinely SAVE it, then I have a tutorial for that on Techority, but it sounds more like you just want to know at the end of the app what was chosen, not for all time. (As in, no need to actually save data.)

You’d have, for example, a variable in question 1 called “_G.q1chose” or the like. When a user picks an answer and you change scenes, in that same function, for answer 3, you’d do “_G.q1chose = 3”

Then on your final screen you’d simply say that if _G.q1chose = 3 then _______

The _______ obviously being where you’d display new text to state their choice, or the like.

Hope that helps :slight_smile:

Peach [import]uid: 52491 topic_id: 10277 reply_id: 37594[/import]

You’re basically creating a “quiz” application? This is definitely possible, and not too complex. :slight_smile:

If you can keep your entire application “local” (as in, you don’t need Director to display different modules for each scene), you can avoid the global variables (_G.var) that Peach suggests. If you are using Director and external modules, I’m afraid you will need those globals.

However, in either case, you could simplify it to just 1 global or 1 local variable and store the results in a table, as follows:

local userChoices = { 0,0,0,0,0,0,0,0,0,0 } --ten spaces, for ten questions

Then just set them when necessary, for example: userChoices[1] = 3

This would at least keep it down to one global or local tracking table, which is probably easier to handle.

If you want to avoid the globals outright, you’ll need to create a singletons method similar to this: http://developer.anscamobile.com/forum/2011/04/28/singletons-lua

Brent
[import]uid: 9747 topic_id: 10277 reply_id: 37831[/import]

Hi Brent

Thanks for taking the time to respond and provide advice. I am just getting my head round Director Class so I would prefer to use this. I don’t understand modules so I am not sure if I will have them or not! Apologies if this sounds basic. To all intent and purposes, it basically is just a quiz I want to create. I suppose I have 8 ‘rounds’ in the quiz, 1O questions in each round (there are only 10 in the same order every time) Player has 2 choices and clicks choice button to choose. There are no right and wrong answers and I need the information from each round ‘saved’ so that at the end of the
8 rounds he/she can review what he/she said in each round.

Does this sound like I need modules?

Thanks again

Bob [import]uid: 45029 topic_id: 10277 reply_id: 37832[/import]

Hi Bob,

Director and modules aren’t required for this. Developers use Director primarily for transitioning between full, complex scenes (i.e. levels in a game), or to keep their code more organized in distinct Lua files other than “main.lua”.

Using Director might make some aspects of your quiz easier, but it makes other aspects much more complicated. I would suggest just coding it locally in “main.lua” and maybe organizing/storing the data in tables (as I mentioned before) instead of numerous individual variables.

Best of luck!
[import]uid: 9747 topic_id: 10277 reply_id: 37840[/import]