inkjs icon indicating copy to clipboard operation
inkjs copied to clipboard

Typing changes for VariablesState and Story

Open evanwalsh opened this issue 3 years ago • 1 comments

Checklist

  • [x] The new code additions passed the tests (npm test).
  • [x] The linter ran and found no issues (npm run-script lint).

Description

This makes the experience of using inkjs from TypeScript slightly better by:

  1. Adding typed access to a story's VariablesState. Now, a TypeScript user can do story.variablesState['name'] or story.variablesState.$<string>('name') and either get the convenience that the indexed access affords or the typed access via the generic param of $. Also, the $ function didn't allow for fetching a value without a TypeScript error. That's fixed!

  2. In Story.BindExternalFunction, the lookaheadSafe parameter is now false by default. According to Ink's source:

    Usually, you want to pass 'false', especially if you want some action to be performed in game code when this function is called

    As far as I can tell from the C#, false should generally be the default. This makes the specs' usage of BindExternalFunction correct and saves TypeScript users from having to pass true or false everytime!

evanwalsh avatar May 19 '21 00:05 evanwalsh

Hello, thank you for all 3 PRs! I've had a quick look already and they all seem interesting, I will try my best to do a review as soon as possible… but it might be a few days :)

y-lohse avatar May 19 '21 08:05 y-lohse

Next release :

  • Behaviour of variablesState has been modified in latest.
  • Added default true to lookaheadSafe

smwhr avatar Oct 21 '22 13:10 smwhr