|
|
|
|
Reply From: |
Inces |
You just need to have a class of a node with those enums.
extends RigidBody2D
class_name Player
enum items {sword,shield}
From that moment You can call from everywhere in the script :
Player.sword
Hi, maybe I wasn’t clear at all, I know how to use an enum, I was asking how to show a list of enum’s values when I set arguments in a call func that use them. Even using class_name that list didn’t appear, do you have an example in func build?
Covenauta | 2022-03-10 23:01
Introducing a class to system is all it takes to show its enum list from everywhere You call. Once You create a class using class_name Godots compiler shows it in a node list and autocompletes in editor. In example above I created Player class. Now I can start writing in random script “Pl” and editor will autocomplete “Player”. Now if I input dot : “Player.” compiller will show every function and every enum of Players script, including .sword and .shield. It works the same way as You use Tween.TRANS_BACK
Okey, now I understand a bit more about Godot thanks for it, I didn’t know how class_name really works, but look this
I set class_name
extends KinematicBody2D
class_name Player
now it works as you said everywere, thanks
but as you can see in the pictures I did not write Tween. I came to the last 2 arguments and automatically appear a list that includes tween.enum’s values, I am sure there is someting on this func to show a specific enum automatically in that argument, only for wirte “,” before is needed the enum
this is not happening when I use equip(), then I realise something
but I haven’t success
you reserve a vote for your time, I will try to be more specific on my questions, have a good day.
Covenauta | 2022-03-11 20:09
Aaah ok I finally understood what You meant
I did some digging and found article covering that :
Static typing in GDScript — Godot Engine (stable) documentation in English
unfortunately, it specifically says, that it is impossible to cast enums in Godot :(. That means compiler can’t be informed about variable being enum, and it will never autocomplete like built_in Tween enum
Hooo well, thanks for it, even it is impossible I learned some useful things, take your best answer!
Covenauta | 2022-03-11 22:15