peter-kish / gloot

A universal inventory system for the Godot game engine.
MIT License
625 stars 28 forks source link

[3.0.0] Suggest to change size format #226

Open Nordsoft91 opened 2 months ago

Nordsoft91 commented 2 months ago

I checked out 3.0.0 branch, hopefully you have time to release it eventually!

Instead of having size in this format "size": "Vector2i(2, 2)", here are 2 alternatives: "size": [2, 2] or "size": {"width": 2, "height": 2}

Using "Vector2i" forces to have assumption that other types are supported. Also, it's counter-intuitive, that expected value is string, parsed as some function.

peter-kish commented 2 months ago

The main reason why Vector2i(x, y) is used for item sizes is because var_to_str and str_to_var are used for serialization and deserialization of all item properties. Despite that, it is still possible to use a different format for item sizes, but that would make it inconsistent with other property types (e.g. Color, Quaternion etc.`).

"size": [2, 2] "size": {"width": 2, "height": 2}

I'm afraid these would cause even more confusion because [2, 2] represents an array and {"width": 2, "height": 2} represents a dictionary. On the other hand, Vector2i(2, 2) is at least consistent with the type the plugin uses internally.

it's counter-intuitive, that expected value is string, parsed as some function

Unfortunately, that's a JSON limitation because it only supports numbers, strings, bools, arrays and objects (dictionaries). You can't really do something like "size": Vector2i(2, 2) in JSON.

hopefully you have time to release it eventually!

I hope that too 🙂 I've been quite busy lately and didn't have much time to work on the plugin 😬.