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?

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.
This site is now closed.
As of 1st November 2015, this site is a read-only archive. For more information see the intfiction forum post

Welcome to IF Answers, a site for questions and answers about Interactive Fiction.

Technical questions about interactive fiction development tools such as Inform, Twine, Quest, QuestKit, Squiffy, Adrift, TADS etc. are all on-topic here.

Non-technical questions about interactive fiction are also on-topic. These questions could be about general IF design, specific games, entering the IF Comp etc.
...