INI to variable bug

For questions about using Classic.

Post » Sun Dec 19, 2010 6:46 am

I just found a bug that was driving me crazy!

I setup an INI file for saving purposes and each sprite has its own item which is a string.

So it would look like

[GROUP]
Sprite1=Sprite1.x|Sprite1.Y|Sprite.Value('A')|Sprite.Value('B')

And the problem is when I load and use GetToken(INI.ItemString("Group", "Sprite1"), 3, "|") to load the 3 token into a NUMBER variable of the sprite, Construct makes the variable to a STRING variable, which causes all sorts of problems when adding and such.

I'll add 20 to Variable A which is already at 100, and instead of it being 120, it is 10020.

I thought I'd point it out.

Is this a bug?
Follow me on Twitter @evgLabs
B
33
S
14
G
4
Posts: 251
Reputation: 4,049

Post » Sun Dec 19, 2010 8:52 am

My guess is ... :

1 - INI.itemstring returns a string

2 - GetToken("whatever") returns a string too

It might work if you convert to int :

[code:1dtfcahc]int(GetToken(INI.ItemString("Group", "Sprite1"), 3, "|"))[/code:1dtfcahc]

Also, maybe you have to use INI.ItemValue instead of itemstring?
B
4
S
1
G
2
Posts: 91
Reputation: 1,057


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 6 guests