inkle / ink

inkle's open source scripting language for writing interactive narrative.
http://www.inklestudios.com/ink
MIT License
4.14k stars 492 forks source link

Float variables are printed with either comma or dot based on system regional settings #916

Open tarnos12 opened 1 month ago

tarnos12 commented 1 month ago

Issue: story.CurrentTags returns a tag with a float value either comma or dot separated (0,15 and 0.15) "audioambient:asset\'ambient_sanctuary_deep\',volume\'0,15\',loop\'0\'" or "audioambient:asset\'ambient_sanctuary_deep\',volume\'0.15\',loop\'0\'"

Cause: The reason is that those values are taken from a variable which seem to be converting floats based on system regional settings(No Invariant Culture is being used) This makes tags inconsistent as this persist on a compiled game and happens both in inky editor, Unity engine or in a compiled game.

Test: Regional Settings in Win11: Control Panel -> Region -> Format -> Switch between USA/Polish to see the difference. You have to restart a compiled game or exit/enter playmode or restart ink editor with double arrow

Inky code:

VAR testFloat = 1
VAR constVal = 0.0001

Test {testFloat * constVal}

This will print 0.0001 or 0,0001 based on system region format in inky editor, unity playmode, compiled game.

Extra Context We have had a short discussion on discord, but I tried to include most of it in this issue. https://discord.com/channels/329929050866843648/471562851346153474/1290727976824209470

Might be related: https://github.com/inkle/ink/issues/842 This reply has a code that seems to be converting floats with .ToString() https://github.com/inkle/ink/issues/842#issuecomment-1546962577

I will test it if I can find that script.