Login
Remember
IF Answers
Ask a Question

# In Quest, how do I send an integer from javascript to Quest and keep it an integer?

0 votes
431 views
asked Jun 18 in Authoring by lightwriter (5 points)

Let's say I have a Javascript function that gets the date, I used ParseInt but it still sends the variable as a string even though Javascript reads it as a variable but Quest reads it as a string.
Is there a way to keep it as an integer or will anything Javascript sends to Quest be converted to a string?

- quest
- javascript

## 1 Answer

0 votes
answered Jun 19 by hegemonkhan (161 points)
selected Jun 19 by lightwriter
Best answer

I'm just learning JS at code academy so this is still way beyond me, and this probably won't help, but there is this in quest:

http://docs.textadventures.co.uk/quest/functions/toint.html

    player.strength_string = "50"
    player.strength_integer = 50

    player.strength_integer = ToInt (player.strength_string)
    player.strength_string = ToString (player.strength_integer)

    so if you could somehow do this:

    VARIABLE = ToInt (JS_function_that_that_gives_quest_the_value_as_a_string)

useful links:

http://docs.textadventures.co.uk/quest/functions/ (categorical order)
http://docs.textadventures.co.uk/quest/functions/index_allfunctions.html (alphabetical order)
http://docs.textadventures.co.uk/quest/scripts/
http://docs.textadventures.co.uk/quest/types/ (Attributes)
http://docs.textadventures.co.uk/quest/elements/ (the OBJECTS of OOP:Object oriented Programming quest)

commented Jun 19 by lightwriter (5 points)
Thanks! I was trying to use cast but that didn't work... I didn't realize there was also a ToInt function.

## Related questions

- How do I give an object to a character and receive something back?
- How do I retrieve values from a dictionary in Quest 5.6?
- Do I have to specify difficulty and cruelty in Quest?
- Quest Gamebook: How to use AND OR and NOT inside an "if" command?
- How do I turn a Quest game into an app?

...