0 votes

I'm building a skill system and currently facing the following challenge:
I have skill1, skill2, skill3. The different skill levels are stored in a global script PlayerStats as values of the variables skill1level, skill2level, skill3_level.
When a point is assigned to a skill in my GUI script, I would like to update the level in the PlayerStats based on which skill got points assigned. Since the selected skill is already stored in a skill variable within my GUI script I would like to avoid going through all the if/elif/else nonsense to set the new level.
I have used something similar in the script to get the current level of the skill:

PlayerStats.get(skill + "_level")

But I've been unable to figure out how to set (or rather, +1) that value.

Godot version 3.3 stable
in Engine by (55 points)

1 Answer

+1 vote
Best answer
PlayerStats.set(skill + "_level", PlayerStats.get(skill + "_level") + 1)
by (8,155 points)
selected by

Thanks, this will come in very handy.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.