Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #440064 Score: 0
    Profile photo of Therese Michael
    Therese Michael
    Member
    beginner
    intermediate
    curious george
    wise owl
    friend finder
    contributor
    picture perfect
    1 pt
    @tmichael9734

    Hi Everyone,

    I’m designing a game where users roll two dices and then pick the question to answer. Rolling the dices activates all questions’ buttons.  Is there a way to activate only the button that associates with the total numbers on the dice tiles? For example, if the total number of dice tiles shows 10, then question 10 only becomes active.

    I know this needs a variable, but I was not able to reach to it thus far.

    Thank you,

    #440068 Score: 0
    Profile photo of Tim K
    Tim K
    Member
    contributor
    beginner
    intermediate
    advanced
    friend finder
    junior moderator
    advocate
    wise owl
    curious george
    Group Member
    352 pts
    @timk

    How did you program the dice … without variables to decide which value each shows?

    #440148 Score: 0
    Profile photo of Therese Michael
    Therese Michael
    Member
    beginner
    intermediate
    curious george
    wise owl
    friend finder
    contributor
    picture perfect
    1 pt
    @tmichael9734

    Thank you Tim.  Here’s what I did:

    1- Saved images for each tile of each dice.

    2- Grouped the 6 images and called them Dice 1; same with the other 6 images and called them Dice 2

    3- Created 2 variables and called them Dice 1 and Dice 2

    4- On the Roll button I added actions to Modify the Variable of Dice 1 to set to Random (0,6), and then Change Content of the dice image to the side image if the dice variable is equal to 1, 2, etc.  For instance: Change Content, Target: Dice, Resource: Dice-side 1 If Dice_1 (the variable) is Equal to 1; and so on. (please see attachments).

    So basically, I didn’t use calculations to roll the dice. I just enabled and disabled the questions buttons with the click on the Rolling button, and used the Move to action to move the dice while rolling.

    Now, I want to do some math and enable only the question when the sum of the two dices’ sides is equal to the number of question.  For example, the two dices’ total is 6, then question 6 becomes active.

    How do I do that?

    Thank you

    #440174 Score: 0
    Profile photo of Tim K
    Tim K
    Member
    contributor
    beginner
    intermediate
    advanced
    friend finder
    junior moderator
    advocate
    wise owl
    curious george
    Group Member
    352 pts
    @timk

    So, you do know how variables work… the math part is simpler than what you’ve got so far. Just create a third variable, e.g. “Both_Dice”, and two actions after those that randomly set the two dice:

    On: Click
    Action: Modify variable
    Target: Both_Dice
    Type: Set equal to
    Value: VAR(Dice1)

    On: Click
    Action: Modify variable
    Target: Both_Dice
    Type: Add to variable
    Value: VAR(Dice2)

    … make sure it matches the correct names, yours won’t have blanks have they?

    “Both_Dice” now contains the sum of the two value.

    Then add actions similar to those changing the images:

    Action: Set state
    Target: Button 1
    State: Enable

    If “Both_Dice” equal to “1”

    You’ll need 1 for each button / for each value “Both_Dice” might have.

    #440186 Score: 0
    Profile photo of Therese Michael
    Therese Michael
    Member
    beginner
    intermediate
    curious george
    wise owl
    friend finder
    contributor
    picture perfect
    1 pt
    @tmichael9734

    That was easy!!!

    Thanks a lot Tim, that solved the problem and assigned the dices to the correct question numbers.

    Thank you so very much,

     

    #446563 Score: 0
    Profile photo of Therese Michael
    Therese Michael
    Member
    beginner
    intermediate
    curious george
    wise owl
    friend finder
    contributor
    picture perfect
    1 pt
    @tmichael9734

    Tim or others,

    One more question on the same topic: Dice Rolling.  How do I limit the results of the rolled dice to the numbers of unanswered questions?  Meaning: if question 9 is answered, I don’t want the dices total to land on 9.  There are 10 questions in this game, and if the users answer 5 questions, they still have to roll over and over until the total lands randomly on an unanswered question.

    Any help please?

    Thank you.

    #446630 Score: 0
    Profile photo of CarlFink
    CarlFink
    Member
    beginner
    intermediate
    contributor
    LUC16 Attendee
    wise owl
    curious george
    advanced
    36 pts
    @CarlFink

    That’s tricky with the Actions system. It would be easy in code, but Actions have no way to handle a list of numbers.

    You can use the question variables (see https://www.trivantis.com/blog/lectora-basics-question-variables/) and a series of Conditions on the goto action to reject going to an already-answered question, but I don’t off the top of my head see an obvious way to trigger the action again. (It would be trivial to pop up a message saying, “Please roll again.” It would also be clunky and frustrating for the user.)

    What is missing is the ability to have an Action trigger itself again if it gets an invalid result.

     

    EDIT: if you are comfortable with even very basic JavaScript (which is all I personally know) you could have the button trigger a script rather easily–that’s a supported Action type. That script could set a variable, and could read the Question variables and make sure the result is limited to un-answered questions.

    • This reply was modified 2 weeks, 2 days ago by Profile photo of CarlFink CarlFink .
    #446689 Score: 0
    Profile photo of Therese Michael
    Therese Michael
    Member
    beginner
    intermediate
    curious george
    wise owl
    friend finder
    contributor
    picture perfect
    1 pt
    @tmichael9734

    Thank you Carl.  I know it is rather very difficult with variables and actions than if it is built in Java Script.  Unfortunately, I’m clueless in Java Scripts.  All what I know is to copy and paste them but cannot create them.

    Many thanks again for your attempt though:)

    #446710 Score: 0
    Profile photo of CarlFink
    CarlFink
    Member
    beginner
    intermediate
    contributor
    LUC16 Attendee
    wise owl
    curious george
    advanced
    36 pts
    @CarlFink

    It’s times like this I miss Asymetrix ActionScript.

    #446713 Score: 0
    Profile photo of Therese Michael
    Therese Michael
    Member
    beginner
    intermediate
    curious george
    wise owl
    friend finder
    contributor
    picture perfect
    1 pt
    @tmichael9734

    True! Thank you Carl:)

    #446730 Score: 0
    Profile photo of Tim K
    Tim K
    Member
    contributor
    beginner
    intermediate
    advanced
    friend finder
    junior moderator
    advocate
    wise owl
    curious george
    Group Member
    352 pts
    @timk

    Here’s a sample how it can be done with Lectora alone. It does require quite a lot of actions…

     

    Attachments:
    1. Roll-Dice.zip
    #446737 Score: 0
    Profile photo of Therese Michael
    Therese Michael
    Member
    beginner
    intermediate
    curious george
    wise owl
    friend finder
    contributor
    picture perfect
    1 pt
    @tmichael9734

    This is nice Tim, thank you for sharing it.  Let me challenge myself now and see if I can apply it.  It’s exactly what I’m looking for!  I wish I can do it.

    #446753 Score: 0
    Profile photo of Tim K
    Tim K
    Member
    contributor
    beginner
    intermediate
    advanced
    friend finder
    junior moderator
    advocate
    wise owl
    curious george
    Group Member
    352 pts
    @timk

    The system uses 5 variables:

    die1value, die2value, totalvalue: These are the same as before.

    repeat: Either “yes” or “no”. It’s used during “Check Results” to decide whether new random values are required for die1value and die2value, because the totalvalue has been rolled before.

    questions: It contains characters, a – k, to represent each possible “totalvalue”, 2 – 12, i.e. a=2, b=3 etc

    The group “Enable …” is what happens when a valid number is rolled. Currently there are two actions for each “totalvalue”.

    If totalvalue = 2, Button 2 is enabled  and “a” (representing “2”) is subtracted from “questions”.

    When another 2 is rolled, “Check Results” will find that “totalvalue = 2” but “questions” Does not contain “a”. “repeat” stays “yes” and the last action the group will run “Randomize Dice” again to receive new values.

    You can use any action you want instead of “Enable Button”, e.g. “Show Question 1” or “Go to page 15”.

    You can move the “Subtract a” action to another location, e.g. to the page with the question, to the check button and give it different conditions, e.g. “If Question 1 is correct”.

    • This reply was modified 1 week, 6 days ago by Profile photo of Tim K Tim K.
    #446768 Score: 0
    Profile photo of Therese Michael
    Therese Michael
    Member
    beginner
    intermediate
    curious george
    wise owl
    friend finder
    contributor
    picture perfect
    1 pt
    @tmichael9734

    Thanks a lot Tim, this is a very helpful explanation.  I wish I had had these variables even before I design the game.  My challenge is that my game has already its own variables that do other functions besides the dice rolling.  I’m trying to merge yours with mine, while maintaining those functions running.  With the many actions, it’s quite difficult to manage all of them.

    I’ll keep you posted…

    Many thanks again,

     

Viewing 14 posts - 1 through 14 (of 14 total)

You must be logged in to reply to this topic.