[B624] Lua - SetKeyValue/GetKeyValue bug with floating point values

Post bug reports and ask for game support here.

Moderator: MOD_Command

Post Reply
mx1
Posts: 76
Joined: Thu Jan 16, 2014 6:01 pm

[B624] Lua - SetKeyValue/GetKeyValue bug with floating point values

Post by mx1 »

As the SetKeyValue converts the 'value' argument to string it does not work correctly with Windows regional setting that don't use '.' as the floating point separator. This effectively prevents the usage of SetKeyValue/GetKeyValue for floating point values. Buggy code example (local floating point separator is ','):

Code: Select all

 ScenEdit_SetKeyValue("AAA",2.2)
 my_var = tonumber(ScenEdit_GetKeyValue("AAA"))
 ScenEdit_MsgBox("Hi: " .. my_var,8)
 
ERROR: [string "chunk"]:3: attempt to concatenate global 'my_var' (a nil value)

which shows that tonumber() is unable to convert the value back to numerical (the string returned by GetKeyValue() is "2,2" in this example while tonumber expects "2.2").
User avatar
michaelm75au
Posts: 12455
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: [B624] Lua - SetKeyValue/GetKeyValue bug with floating point values

Post by michaelm75au »

This seems to work for me.
What locale are you in?
It may have something to do with your locale setting - I think others have reported similar things

--
Okay I just noticed that was in your post about regional settings. Got side track when posting response.
Image
Attachments
Image4.jpg
Image4.jpg (229.37 KiB) Viewed 41 times
Michael
mx1
Posts: 76
Joined: Thu Jan 16, 2014 6:01 pm

RE: [B624] Lua - SetKeyValue/GetKeyValue bug with floating point values

Post by mx1 »

My locale is Polish (pl). I guess that GetKeyValue() should ignore locale and return string with '.' as floating point separator or that SetKeyValue() should ignore it and write string representing number with '.'.
Post Reply

Return to “Tech Support”