In docs is one page about @GlobalScope . I apparently have access to all constants of enums but not to enum itself. How I can access enum so I can get name of value by its Id ?
Garrom out.
In docs is one page about @GlobalScope . I apparently have access to all constants of enums but not to enum itself. How I can access enum so I can get name of value by its Id ?
Garrom out.
No ? Nobody ? What about you @TwistedTwigleg ? So far, you was one of most helpful members of community.... I don't know but this forum seems to be so empty last few days... No reactions, No new posts, No active users, No life. It seems like this forum becoming a ghost town
@GarromOrcShaman said: No ? Nobody ? What about you @TwistedTwigleg ? So far, you was one of the most helpful members of community...
Well, in theory you should be able to access the enumerators like this (untested):
enum enum_var {Foo = 1, Bar = 2, Godot = 3}
var id = 0
func _ready():
var enum_from_id = enum_var[id]
At least, that is the impression I get from the documentation example.
In theory, another way you could do this is not using enumerators at all, but rather use a constant dictionary. Something like this (untested):
const dictionary = {“Foo”:1, “Bar”:2, “Godot”:3}
var id = 0
func _ready():
var enum_from_id = dictionary.keys()[id]
var access_like_enum = dictionary.Foo
This is the way I would do it, as personally I feel it gives the most flexibility.
I don’t know but this forum seems to be so empty last few days...
I go on vacation and everyone disappears! :lol:
In all seriousness though, the lack of people on the forums these past few days may be related to the Fourth of July (for those who celebrate it / get the day off). I would not be surprised if many, myself included, have decided to take advantage of the Fourth falling on a Wednesday and so took off Thursday and Friday as well (getting a 5 day break, assuming they do not work on the weekends).
Or maybe the forums are just in a quiet phase for now. Activity on the forums seems to come and go, with a few consistent members posting relatively regularly. This seems to be the pattern most/all of the forums I have been a part of.
Things will likely pick up again, there just needs to be some time for it to swing the other way, to a more active/busy phase.
All of this said, I have not really been looking at the forums in the past couple days due to being on vacation, so it’s possible I have missed something, but I do not think there is any reason to worry, at least not for now :smile:
@TwistedTwigleg said:
@GarromOrcShaman said: No ? Nobody ? What about you @TwistedTwigleg ? So far, you was one of the most helpful members of community...
Quote was shorted to prvent wall-o-text Thanks a lot :smile: I'm still looking for way how to access enums stored in GlobalScope. To get you to my situation. I'm working on input right now. I can pull Id from inputEvent and I need access to enums JoystickList, KeyList and ButtonList to get name of used key/button and show it in settings of game. Or you know better way how to get name of key/button from inputEvent ? Problem is, I can access all values of enums but not enum itself so I guess there will be trick to get to mentioned enums (JoystickList, KeyList and ButtonList)
@GarromOrcShaman said: I'm still looking for way how to access enums stored in GlobalScope. To get you to my situation. I'm working on input right now. I can pull Id from inputEvent and I need access to enums JoystickList, KeyList and ButtonList to get name of used key/button and show it in settings of game.
Maybe you could do it like the code below? It seems to work nicely, and if I remember correctly I did something like this for control remapping in a Godot 2 prototype game.
` func _input(event): if event is InputEventKey: print ("Name of key:", OS.get_scancode_string(event.scancode)); if event is InputEventAction: print ("Action pressed:", event.action);
`
Problem is, I can access all values of enums but not enum itself so I guess there will be trick to get to mentioned enums (JoystickList, KeyList and ButtonList)
Yeah, I looked at the documentation and tried a couple things, but for the global scope enums there seems to be no way to access them as a group, it only seems to be accessible individually.
@TwistedTwigleg said:
OS.get_scancode_string(event.scancode))
Wha.. Wait... what ? If I known aboutOS.get_scancode_string
I won't bother you with it. when i know about it, I got together solution below, it is not perfect but I'm happy with it.var event = InputMap.get_action_list(keybind_name)[0] if event is InputEventMouseButton: label.text = "Mouse Button "+ str(event.button_index) elif event is InputEventKey: label.text = OS.get_scancode_string(event.scancode) elif event is InputEventJoypadButton: label.text = "GamePad Button"+str(event.button_index)
@TwistedTwigleg said: Yeah, I looked at the documentation and tried a couple things, but for the global scope enums there seems to be no way to access them as a group, it only seems to be accessible individually. Too bad. I'll write it at GitHub as feature request.
Thanks a lot and sorry for disturbing your vacation.
@GarromOrcShaman said: Wha.. Wait... What ? ...
Yeah, I did not know about it either until I stumbled open in a while back, way back when Godot 2 was new :lol:
Too bad. I’ll write it at Github as feature request
Sounds good!
Thanks a lot and sorry for distrurbing your vacation
No problem, and worry not, you have not distrurbed anything :smile:
It's possible to do Input.get_joy_button_string(int button_index)
@_init said: It's possible to do
Input.get_joy_button_string(int button_index)
I solved problem already. Like two posts ago.
elif event is InputEventJoypadButton:
label.text = "GamePad Button"+str(event.button_index)
This achieve pretty much same effect. Besides that, function you mentioned is undocumented which means it was most likely added in 3.1
Still no way to access the GlobalScope Enums?