Difference on evaluating values from Dictionary object on C3 runtime over C2 runtime

0 favourites
  • 3 posts
From the Asset Store
A cool way for kids to write and practice English Alphabets
  • I'm not sure if its a bug, but just noticed a difference on evaluating values from Dictionary object.

    Examples:

    Lets suppose that the Dictionary.Get("VALUE") = 1

    So we evaluate the following:

    Dictionary.Get("VALUE") * 50

    Result on C2 runtime = 50

    Result on C3 runtime = 1

    To resolve this issue on C3 runtime we just have to use int function:

    int(Dictionary.Get("VALUE")) * 50

    Simple, so not a big deal right? But for those who don't know, it may cause trouble when converting an project from C2 to C3 runtime.

    Btw... Just to let people know.

  • I would guess you actually stored a string of "1" and then multiplied that with a number. I just tried it with both the C2 and C3 runtimes though and "1" * 50 returns "1", as it is supposed to (since string * number returns the string unmodified). So I can't see any change in behavior.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I would guess you actually stored a string of "1" and then multiplied that with a number. I just tried it with both the C2 and C3 runtimes though and "1" * 50 returns "1", as it is supposed to (since string * number returns the string unmodified). So I can't see any change in behavior.

    Oh, so it has to do with the way the value is stored. My mistake.

    Actually I have a 'save' function that saves a value in a dictionary then saves the dictionary.json in localstorage. When I converted it to the built-in-function I had to convert the parameter to string. So I did not noticed that all values in the dictionary are string now.

    Thanks for clearing it up and sorry for the confusion!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)