Howdy, Stranger!

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

Accessing story variables via JavaScript...


Is there a way to access (or retrieve) story variables with JavaScript? For instance, I’d like to use the trim() function on user input in order to ensure that no extra spaces are added after the input string? Is there a way to do this?



  • Again, you need to state which story format you are using as answers can be different for each one.

    Sugacube's History API documentation explains how to access its variables, it is basically

    eg. if you have a variable named $money then you would access it via:

    I am not aware of a simple way to access Harlowe variables via Javscript, maybe someone else like Leon would have a better answer.
  • So sorry... In the current release of Harlowe.

    Thanks for the SugarCube info!
  • re: Harlowe
    I forgot about this hack found by @csalzman to set a variable using a combination of a hook, a live macro and some javascript.
  • Thanks. I’ve seen than one as well, but it seems a little too convoluted for something simple like this (not that there’s currently a better way!).
Sign In or Register to comment.