I’m trying to create a upgrade system for my game where whenever a thing is pressed it will run a function to do an upgrade.
I want the upgrades to be stored in an autoload/inherited script (I’m currently using autoload but it could work through inheritance) and there to be a dropdown in the inspector to set a upgrade from a list. I tried using an array but that’d require it being an integer and knowing which index the upgrade I want is at. I could do a string for the dictionary key but that runs the risk of typos. I could do an enum for the dropdown but those can only be constants and I need them to run functions. I’d want to be able to use a dictionary with an enum style dropdown but I can’t figure out how to make that work. The only thing I could think of doing is kinda like this:
enum thing {
THING_ONE,
THING_TWO,
}
func _whatever_i_call_this_but_it_would_probably_be_called_by_the_player():
match thing:
THING_ONE:
func ():
print('thing one happenes')
THING_TWO:
func ():
print('thing two happenes')
That just seems hard to maintain though because I’d need to add the enum value and the match statement
Is there no winning and I have to accept this or is there a better solution I haven’t thought of?