0
\$\begingroup\$

this works:

func _on_HeadstrongRush_pressed():
    if headstrong_rush_ps < 5:
        if headstrong_rush_ps > 0:
            has_headstrong_rush_skill = true 
        headstrong_rush_ps += 1
        skill_points -= 1
    $AllUIHere/Skills/WardenSkills/Set1/HeadstrongRush/SkillLevel.text = str(headstrong_rush_ps)

so why doesn't this work :

func _on_PomelStrike_pressed():
    if pomel_strike_ps < 5:
        if pomel_strike_ps > 0:
            has_pomel_strike_skilll = true 
        pomel_strike_ps += 1
        skill_points -= 1
    $AllUIHere/Skills/WardenSkills/Set1/PomelStrike/SkillLevel.text = str(pomel_strike_ps)

The error is that I can't compare pomel_strike_ps using < but both variables pomel_strike_ps and headstrong_rush_ps are two integers, side by side.... Chat GTP says that the problem is that the variable is probably not initialized in time, tried to put onready var and nothing changed, tried waiting and nothing changes.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ The error is likely somewhere else, either where you define the variables or somewhere else you assign them, which you didn't include in the question. Here is a suggestion: declare the variables with the int type explicitly, so Godot will throw an error if they are being used as something other than an integer somewhere else. \$\endgroup\$
    – Theraot
    Commented Dec 15, 2023 at 20:37

1 Answer 1

0
\$\begingroup\$

Apparently it was a bug, solved it by deleting this line in the savedata section of the script:

if "pomel_strike_ps" in player_data:
    pomel_strike_ps = player_data["pomel_strike_ps"]

I started the game, played it and it didn't crash. Then I did control + z to return the deleted code, and it worked.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ So you say this is savedata. It could have been that the savedata was corrupted. Then when you removed this, it saved again but without that value. So next time running the code the incorrect value wasn't there to cause problems anymore. \$\endgroup\$
    – Theraot
    Commented Dec 15, 2023 at 20:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .