peter-kish / gloot

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

Gloot fails to return string property started from number #212

Closed Nordsoft91 closed 3 months ago

Nordsoft91 commented 3 months ago

item protoset

{
    \"id\": \"snack_food\",
    \"description\": \"150 kcal\"
},

code

var descr: String = item.get_property("description", "")

Expected result:

Actual result:

Снимок экрана 2024-05-24 в 14 41 03
peter-kish commented 3 months ago

I did a bit of investigation and this seems like a Godot problem. str_to_var returns a variable of type int whenever a string begins with a digit. This behavior is also inconsistent with String.is_valid_int():

var s: String = "1a"
print(s.is_valid_int()) # prints false
print(typeof(str_to_var(s)) == TYPE_INT) # prints true

I'll probably open an issue in the Godot repo. or not... it might be intentional. I think I can come up with a quick workaround.

peter-kish commented 3 months ago

Should be fixed in v2.4.9.