Number Variable

mmalhotra-9265
mmalhotra-9265 Community Member Posts: 320 ♪ Opening Act ♪
Hi,

How do I implement number variable in Lectora?
Example as below:





Regards
Malvika

Comments

  • carlfink
    carlfink Community Member Posts: 960 ✭ Legend ✭
    Lectora doesn't have variable types.

    If you assign a number to a variable, it's a number variable. You can use the Actions for numbers (say, "Add 1 to myVariable") and test for values ("If myVariable is less than 2, move the photo off the screen") and it will work.

    Note: I am not using actual Action syntax above.
  • andrew-robertson
    andrew-robertson Community Member Posts: 185 ☆ Superstar ☆
    edited June 15, 2021
    Make your four images buttons or at least transparent buttons. See screenshots below.

    New variable:


    Button for healthy options:


    Button for unhealthy options:



    Andrew R.
    Developing content since 2010 using a mixed bag of tools.
  • mmalhotra-9265
    mmalhotra-9265 Community Member Posts: 320 ♪ Opening Act ♪
    Noted Carl.

    I added action 'Modify Variable' with Add/Subtract Variable but it isn't doing any action for me.

    Regards
    Malvika
  • mmalhotra-9265
    mmalhotra-9265 Community Member Posts: 320 ♪ Opening Act ♪
    @andrew-robertson - I tried it without transparent button. (saw your message later).
  • andrew-robertson
    andrew-robertson Community Member Posts: 185 ☆ Superstar ☆
    edited June 15, 2021
    You've done it wrong, you don't have a button anywhere on the item. Your activity images have an OnShowModVar action. Also what is your end plan? Show a total point score? Show a score per item?



    See the screenshot below as to how I would have handled this request.

    BananaBTN-dedicatedVariable
    • On mouse click: modify _Banana variable set equal to 2.
    BananaBTN-oneVariable
    • On mouse click: modify _totalHealthyScore variable by adding 2 to the current score.


    Please take a look at my examples I posted in a preview response that will show you exactly how to do it - with an image button or transparent button.
    Andrew R.
    Developing content since 2010 using a mixed bag of tools.
  • mmalhotra-9265
    mmalhotra-9265 Community Member Posts: 320 ♪ Opening Act ♪
  • andrew-robertson
    andrew-robertson Community Member Posts: 185 ☆ Superstar ☆
    Yep. So you'll want to use the BananaBTN-oneVariable solution I provided above.
    Andrew R.
    Developing content since 2010 using a mixed bag of tools.
  • mmalhotra-9265
    mmalhotra-9265 Community Member Posts: 320 ♪ Opening Act ♪
    @andrew-robertson - I have added the suggested actions. There seems to be some miss.

    Score is not reflecting in total column, nor it reflects when I click on banana or other elements.

    Regards
    Malvika
  • carlfink
    carlfink Community Member Posts: 960 ✭ Legend ✭
    Malvika, you have two buttons for each graphic. Only the top one is triggered by mouse clicks, so the one under it, which modifies _TotalHealthy, never triggers. You can put both actions on a single button, instead of using two buttons.
  • mmalhotra-9265
    mmalhotra-9265 Community Member Posts: 320 ♪ Opening Act ♪
    @carlfink - I tried having two actions under one button.


  • carlfink
    carlfink Community Member Posts: 960 ✭ Legend ✭

    @carlfink - I tried having two actions under one button.

    And what happened when you tried it?
  • mmalhotra-9265
    mmalhotra-9265 Community Member Posts: 320 ♪ Opening Act ♪
    It doesn't seem to reflect any count of banana or burger?
    File as attached.
  • mmalhotra-9265
    mmalhotra-9265 Community Member Posts: 320 ♪ Opening Act ♪
    I tried this link - but not sure about 'Change Content' action.

    It doesn't seem to work.
  • mmalhotra-9265
    mmalhotra-9265 Community Member Posts: 320 ♪ Opening Act ♪
    Any thoughts on how can I make this work?
  • mmalhotra-9265
    mmalhotra-9265 Community Member Posts: 320 ♪ Opening Act ♪
    Any thoughts on how can I make this work?
  • andrew-robertson
    andrew-robertson Community Member Posts: 185 ☆ Superstar ☆
    See attached.
    Andrew R.
    Developing content since 2010 using a mixed bag of tools.
  • andrew-robertson
    andrew-robertson Community Member Posts: 185 ☆ Superstar ☆
    @mmalhotra-9265 did this work for you?
    Andrew R.
    Developing content since 2010 using a mixed bag of tools.
  • mmalhotra-9265
    mmalhotra-9265 Community Member Posts: 320 ♪ Opening Act ♪
    Yes Andrew, it worked for me. Your file became my bible, and helped.
    Thank you.