Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't enumerate variables without accessing private attribute _globalVariables #1058

Open
drpepper opened this issue May 10, 2024 · 0 comments

Comments

@drpepper
Copy link

Describe the bug

Hello! I'm new to ink and inkjs, but so far I'm loving it!

For my project, I would like to be able to list all variables and their values in order to see and modify them as the game plays.

I can access individual variables through the Story.variablesState proxy, but I haven't found a way to enumerate them.

Right now I'm using a hacky way to do it, by accessing the private attribute Story.variablesState._globalVariables directly, and ignoring the TypeScript error.

Is there a better way to do this? If not, what about adding [[OwnPropertyKeys]] to the proxy?

To Reproduce

Try to enumerate variables like: Object.keys(Story.variablesState).

Expected behavior

Object.keys(Story.variablesState) should provide an array of variables.

Environment

  • OS: macOs
  • Web browser version: Chrome 124
  • inkjs version: 2.2.2

Additional context

Thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant