godot icon indicating copy to clipboard operation
godot copied to clipboard

Add `typeof_string()` utility

Open Kubulambula opened this issue 3 years ago • 3 comments

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))

Kubulambula avatar Dec 05 '22 21:12 Kubulambula

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.

MewPurPur avatar Dec 05 '22 21:12 MewPurPur

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

MewPurPur avatar Dec 05 '22 22:12 MewPurPur

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 avatar Dec 05 '22 23:12 Kubulambula

@Kubulambula Is this PR ready? I would love this feature, and it could make 4.1.

20milliliter avatar May 27 '23 14:05 20milliliter

@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.

Kubulambula avatar May 27 '23 14:05 Kubulambula

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?

Kubulambula avatar May 27 '23 14:05 Kubulambula

I think it would, yes. type_string() would make it consistent with the error_string() method.

20milliliter avatar May 27 '23 14:05 20milliliter

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.

MewPurPur avatar May 27 '23 22:05 MewPurPur

Need to rebase the branch and resolve conflicts.

dalexeev avatar Sep 22 '23 11:09 dalexeev

Need to rebase the branch and resolve conflicts.

Should be good now.

Kubulambula avatar Sep 24 '23 20:09 Kubulambula

You've incorrectly rebased and instead reset all the commits

AThousandShips avatar Sep 25 '23 17:09 AThousandShips

You've incorrectly rebased and instead reset all the commits

I am trying 😭

Kubulambula avatar Sep 25 '23 17:09 Kubulambula

I'd suggest copying down your changes, doing git reset --hard master and then adding your code back in as a single commit

AThousandShips avatar Sep 25 '23 17:09 AThousandShips

Use git push --force when pushing your changes instead of making merge commits :)

AThousandShips avatar Sep 25 '23 18:09 AThousandShips

@AThousandShips I think that I somehow fixed it. Thank you for your help and patience with me ❤️

Kubulambula avatar Sep 25 '23 18:09 Kubulambula

Thanks! And congrats for your first merged Godot contribution :tada:

akien-mga avatar Oct 03 '23 15:10 akien-mga