So, a weird question. I have been using JSON to load/save my games because the dictionary is useful. But I have a problem. I have been trying to store a Vector2() but it keeps returning as a string when I load it. I have debugged the variable and it does have two values in captions. I did sanitize it to the global using Vector2() beforehand but all loads come back as a string of those two numbers in captions and not a vector. I am certain it's because it is storing as a string because that's the error code, which may be related to JSON. How do I parse this to a Vector2 when it stores/loads as a string?

  • xyz replied to this.
  • SnapCracklins Use str2var() but prefix the string you get from json (two numbers in parenthases) with "Vector2"

    SnapCracklins changed the title to Trouble storing/retrieving Vector2 data in JSON .

    SnapCracklins Use str2var() but prefix the string you get from json (two numbers in parenthases) with "Vector2"

    You're a gentleman and a scholar. I also had to var2str() the input for some reason when saving before loading with str2var()? Still learning obviously. Thanks to you!

    • xyz replied to this.

      SnapCracklins I also had to var2str() the input for some reason when saving before loading with str2var()? Still learning obviously.

      In that case you don't need to use the prefix because the stored string will be in form "Vector2(1, 1)" which can be passed directly to str2var()

        xyz ah! even better. I'll take one less level of abstraction anyday. Much obliged! (And this worked, obviously.)