Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Burloe |
Hi, I’m attempting to make a keybinding menu loosely following this tutorial. I’ve got my actions in a .json file and store that in a dictionary within an autoload script. Within each action there’s a sub-dictionary(I think, I hardly understand what I’m doing). To keep this short, lets focus on the jump action and one joybutton(I have two for each input type). Here’s that key in the dict:
"gp_jump": { "primary_gp" : "JOY_BUTTON_A" },
Then I have a scene filled with sprites to show what button is active for each action and to it is a script. In that script I loop through the keys in the dict and if index == action_name(the name of the project settings keybinds). If I print index, I only get “gp_jump”(without “”). Not any of the keybinds, just the action name and nothing else.
Anytime I try to access any information within with something like i[primary_gp], I’m of course just getting errors because I can’t access the information further in. If I print the dictionary I get the entire thing printed, subdicts and all.
The idea is to then pass in the keybinding into the set_gp_button() function and use that to set the icon. I’d really appreciate any help. Thanks in advance!
In case the image doesn’t load. Here the code:
func find_this_key():
for i in KeybindManager.key_dict:
print(i)
if i == action_name:
set_gp_button(prim_gp_btn, i.primary_gp)
func set_gp_button(what_button : Button, index_and_button_key):
if index_and_button_key == JOY_BUTTON_A:
what_button.frame = 4
Burloe | 2023-03-26 10:49