Nerdzmasterz Yeah but, my goal here is to replace the wall of if/else statements that I had. I mean, they're gone now and my code seems to be working alright, I just wanted to remove that for loop fro the process function just in case in causes future problems( though I don't see any problems now).
Another potentional problemt( that hasn't arised yet) is that I could get some sort of error if I press two weapon number buttons at the same time. Even though I didn't get the error when I pressed multiple number keys at once, it this could help since I've gotten there is no elif code in this arrangement.
Anyway, I found some sort of way to moe the for loop outside of the process function with something like this:
func _input(event):
if event is InputEventKey:
for i in 6:
if i !=0:if Input.is_action_just_pressed("weapon"+String(i)) and i-1 in weapon_numbers:weapon_switching(weapon_numbers.find(i-1))
Of course, all the other problem I might fear could still come up in the future, which is why I want to solve it now. I know I'm basically trying to fix what isn't broken, since my game was working just fine with that wall of if/else statements. However, I want to take programming more seriously and get better at it until it becomes second nature.
Right now, I've solve the problem of this loop from running repeatedly in process. Now I have to find a way to get it to stop running when I'm not precessing any of the number keys and I have an idea as to how. The only problem that I have no idea to solve is what I'd do without that elif condition. I know that it doesn't seem like a problem now but, I want to be thorough.
Edit: Okay, so I don't know how to get it to stop running when I'm not pressing the number keys. 😆