Add `typeof_string()` utility
Closes #1860
Adds typeof_string() method, using Variant::get_type_name() effectively just exposing this method to GDScript.
This method goes hand in hand with the already implemented error_string() utility. Both of these methods are extremely useful for plugin development where user interaction is expected.
The proposal describes a method that prints the name of the variable directly without the typeof() step between. But I believe that this makes this function more versatile and a method like that can be simply made like this:
func typeofname(x):
return typeof_string(typeof(x))
Regarding the PR itself: I love this feature and I'll be using it a ton in debugging. But since 4.0 is in feature freeze and this doesn't fix any bugs, it will likely not make the cut for now.
Since this is a small feature, the commits need to be squashed into one. Here's a link to our tutorial on this: https://docs.godotengine.org/en/stable/community/contributing/pr_workflow.html#the-interactive-rebase
Since this is a small feature, the commits need to be squashed into one. Here's a link to our tutorial on this: https://docs.godotengine.org/en/stable/community/contributing/pr_workflow.html#the-interactive-rebase
Thanks! I always find a way to mess my branch up
@Kubulambula Is this PR ready? I would love this feature, and it could make 4.1.
@Kubulambula Is this PR ready? I would love this feature, and it could make 4.1.
Yes it should be ready as it does not change anything and just exposes an already present function and is just waiting for approval.
After looking at it though, maybe type_string() would be more fitting?
Because you get the name of type that you get from typeof() and typeof_string() implies that is gets the string type of something.
Any thoughts?
I think it would, yes. type_string() would make it consistent with the error_string() method.
This is clearly the correct implementation, I think it's a matter of whether we approve of the feature and if so, when we get to merging this. And I also prefer type_string() personally.
Need to rebase the branch and resolve conflicts.
Need to rebase the branch and resolve conflicts.
Should be good now.
You've incorrectly rebased and instead reset all the commits
You've incorrectly rebased and instead reset all the commits
I am trying 😭
I'd suggest copying down your changes, doing git reset --hard master and then adding your code back in as a single commit
Use git push --force when pushing your changes instead of making merge commits :)
@AThousandShips I think that I somehow fixed it. Thank you for your help and patience with me ❤️
Thanks! And congrats for your first merged Godot contribution :tada: