Forum rules - please read before posting.

Variable: set as input element and check variable value

I’m using an input element to let the user input a number with a decimal point, like 0.2, and then check the value equal to 0.2.

When I set input type as Numberic Only, I can’t input decimal point in the input box.

While I set input type as Allow Special Characters, and create a global string variable. In Actionlist Editor, first Variable: Set as Menu Element, then in Variable: Check, the value is compared with 0.2. In the run time, when I input 0.2, I can see the Variable indeed changed to 0.2, however, the condition of equaling to 0.2 is always not met.

Am I missing any key step, or is there another solution to check input context with decimal number?

The following image is my actionlist when running the progress.

Comments

  • Welcome to the community, @ninetynine99.

    Looks like there's something funny going on with string comparisons. It would be best to rely on a Float variable and compare that instead.

    You'll still need the String variable to update from the Input box, but if you create another Float variable, you can copy that from the String variable.

    Create a new Float, and - in between the first and second Actions in your screenshot - insert a Variable: Copy Action that copies the string Variable onto the float. So long as it's a valid number, it should get converted.

  • Thanks Chris for replying me so quickly. I have tried to create a float variable and insert a Variable: Copy action between Variable: set and Variable: Check.

    If the Variable: Set as a label element, the value could be converted to a float and comparison works. While the Variable: Set as an input element, in the run time the string variable can’t be converted to a float variable, and the comparison also doesn’t work.

    I also tested that set input type as Numberic Only, the Variable: Check can success to recognize the input context. It seems to only the Allow Special Characters has this problem.

  • I'm afraid I don't follow. Can you share screenshots showing the Actions you're running, as well as the variables they reference?

    In the next AC update, I'll include an option for "Numeric Only" Input boxes to allow decimals - this may solve the issue.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.