Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

User defined variables and conditional actions

New Here ,
May 12, 2016 May 12, 2016

Hi all

I am using Captivate 6 on a Windows machine and am trying to create a scneario where the user attempt to crack the code on a safe. I have an image of a standard 0-9 numeric keypad and an additional 'enter/submit' button and have click boxes assigned to each digit.

What I want to do is allow the users to have unlimited attempts to crack the 4-digit code and open the safe but I only want them to discover if they have been successful or not when they hit the Enter button - but I have hit a brick wall when creating the actions to identify the correct numbers entered in the correct order.

As an alternative to this method, is there a way to capture the four digit choices of the user into a variable and then test if the resultuing variable score is correct?

Does that make sense for what I am trying to achieve?

Thanks

Simon

353
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , May 12, 2016 May 12, 2016

Of course this can be done by JS, but it is also possible with advanced/shared actions. Since  you are on CP6, shared actions are excluded. Here are some old articles that explain use cases similar to what you want:

Sequence Check - Captivate blog

Create a Keypad-Simulation using Advanced Actions - Captivate blog 

Translate
People's Champ ,
May 12, 2016 May 12, 2016

I think you may need to resort to JavaScript to do this. You will need to push the choices into an array, then populate a user variable with the results.

On your submit button you can evaluate the result with another user variable for the correct combination.

create the user variables

v_enteredCombination

v_correctCombination = 3475

on your click boxes execute the JavaScript submitNum("1")

This will populate the v_enteredCombination.

On the submit button evaluate if v_enteredCombination is equal to v_correctCombination

if it's correct:

do something for correct

if not:

do something for incorrect and reset the array and variable with JavaScript: resetCombination()

Here is the script you can put in the head of the html, I don't think this will work in the JavaScript window.

<script>

var userArray = [1,2,3,4 ];
var tempArray;
var cp = document.Captivate;

//function attached to the number buttons
function submitNum ( num )
{
userArray.push( num );
tempArray = userArray.toString();
cp.cpEISetValue( "m_VarHandle.v_enteredCombination", tempArray.replace( /,/g, '' ) );
}

function resetCombination()
{
userArray = [ ];
cp.cpEISetValue( "m_VarHandle.v_enteredCombination", "" );
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 12, 2016 May 12, 2016

Of course this can be done by JS, but it is also possible with advanced/shared actions. Since  you are on CP6, shared actions are excluded. Here are some old articles that explain use cases similar to what you want:

Sequence Check - Captivate blog

Create a Keypad-Simulation using Advanced Actions - Captivate blog 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 12, 2016 May 12, 2016

Thanks Lilybiri

I don't have any javascript skills at all, but the second example is pretty much what I want to achieve (i must admit I didnt really understand the first example!)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 12, 2016 May 12, 2016
LATEST

You're welcome. If you need more help, just fire away. I also only turn to JS when really necessary...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources