tmedwards / sugarcube-2

SugarCube is a free (gratis and libre) story format for Twine/Twee.
https://www.motoslave.net/sugarcube/2/
BSD 2-Clause "Simplified" License
185 stars 42 forks source link

Javascript Infinity Values Restored From Session As null #220

Closed Mochnant closed 4 months ago

Mochnant commented 1 year ago

When a session is saved/restored (via a manual browser refresh, but this may also impact the default save/load system), Sugarcube variables that are set as Infinity are converted to null, likely due to the use of JSON.stringify();

There are various workarounds, but it would be useful to have native Infinity support.

greyelf commented 1 year ago

@Mochnant I'm curious about when an Author would need to be using or storing the value of Infinity in a Twine project?

Mochnant commented 1 year ago

I have found a use for it in a project I am working on, but I would prefer not to dive too deep into perceptions of the the best way to tackle any particular programming issue.

I've addressed the issue on my end, so this is not a critical issue (for me), but I maintain it would be useful for Sugarcube to behave the way it seems it should. Infinity in, Infinity out. I notice that json5 is already a dependency, so I am hopeful the fix would not be too difficult.

tmedwards commented 1 year ago

I notice that json5 is already a dependency, […]

Not for SugarCube it's not.

[…] so I am hopeful the fix would not be too difficult.

It will not be, no.

Mochnant commented 1 year ago

Apologies, I noticed it was installed when I built from source but that seems to be a node dependency of some sort.

Thanks for adding this to the todo list.

tmedwards commented 1 year ago

No problem. It's likely included by one or more of the development dependencies.