LUA adding a minus sign to a 0 value. Help!
Hi Everyone,
I seem to be stuck where somehow, a minus sign is being added to a saved variable when it's 0. Best as I can tell, when loading the variable it adds the minus sign. I can't figure out why. Anyone have any suggestions? I've manually edited the saved variable file to make the variable just 0 but when I print the variable it says -0. Any help is appreciated! Thanks |
What is the code?
|
Code
I believe this is the first line accessing the data after its loaded:
local playerEP = WebDKP_DkpTable[playerName]["ep_"..tableid]; I manually modify the saved variable file to just 0 instead of -0 and have a whisper command after that to see what it gets. For 0 it returns -0 for all other positive values, they stay positive. It's pretty annoying. |
Issue
Seems like I've isolated it down to where it loads the array from the save variable. When I log out of the game the value is saved correctly as 0. When I go back into the game the value turns into -0.
|
More info
I set up an if statement to print a message if the variable was equal to 0. It was true so it does treat -0 as 0. Unfortunately I don't want it to be displayed as -0 if print it to the screen. Pretty annoying since there is no such thing as -0.
|
"fix"
Alright,
I think there must be some sort of glitch with the api or whatever backend function loads values from the saved vars. Here is how I am getting around the -0: if playerEP == 0 then playerEP = 0; end Pretty hilarious. Anyone else seen this? |
Quote:
|
Code
Ah yeah,
Just a typo in the thread, the code does have the == |
If you round the value before printing, it should go away. You could use something like print( floor( Value * 100 + 0.5 ) / 100 ) to round to 2 decimal places. I tested that with a manually entered -0 and it gave back 0.
|
All times are GMT -6. The time now is 12:50 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI