[Ace]Error while using Himework's excel exp table

I am using Himework's exp table to adjust the exp required for levels
which functions well when I add exp, remove exp, gain level etc
But when I change the class of the character, the error
script "game_actor" 411: ArgumentError occurred
comparison of Fixnum with nil failed
I am using the actor table so changing the class should have no problem.
and I am very sure no other script change anything related to exp, and the error disappears if I remove the script temporarily.
I also checked that the excel file is in csv format.
I am aware that there is a line in the script saying
If your game crashes while comparing exp, it's because your exp tables
are not setup properly.
But I am confused of the instance that the script successfully get the value from the excel and use them in game yet fail to compare it to other variables.
With no programming experience, I cannot understand this.
And I think I have done enough bug-hunting to ask for help.
What is line 411 in your Game_Actor script?
Ruby:
def change_exp(exp, show)
    @exp[@class_id] = [exp, 0].max
    last_level = @level
    last_skills = skills
    level_up while !max_level? && self.exp >= next_level_exp
    level_down while self.exp < current_level_exp                        <---
    display_level_up(skills - last_skills) if show && @level > last_level
    refresh
  end
(of course, there is no arrow in the game script)

edit:
I did more testing and found out that if I input 0 exp on level 1 the error disppears
unfortunately the exp in my project carries real meaning so I cannot set level 1 as 0 exp.
I could force the character exp to become 0,change class, and add it back.
But it would still be helpful to know what went wrong

I've moved this thread to Script Support. Thank you.

The script editor has line numbers on the left hand side. Which line there corresponds to 411?
Ruby:
def change_exp(exp, show)
    @exp[@class_id] = [exp, 0].max
    last_level = @level
    last_skills = skills
    level_up while !max_level? && self.exp >= next_level_exp
    level_down while self.exp < current_level_exp                        <---
    display_level_up(skills - last_skills) if show && @level > last_level
    refresh
  end
(of course, there is no arrow in the game script)

edit:
I did more testing and found out that if I input 0 exp on level 1 the error disppears
unfortunately the exp in my project carries real meaning so I cannot set level 1 as 0 exp.
I could force the character exp to become 0,change class, and add it back.
But it would still be helpful to know what went wrong

The exp table represents how much exp is needed to to from lvl n to lvl n+1. 🙂
So unless your game involves a lvl 0, it is correct to have a 0 for all lvl 1, because it is the start.
Try changing this line:
Code:
level_down while self.exp < current_level_exp

to this:
Code:
level_down while self.exp < (current_level_exp || 0)
(I know this is a bit late)
The game no longer crashes, there is still some minor issues such as once the class is changed, the character will be an undefined level 0 having 1 HP and 1 stats, but this can be circumvented by adding enough exp to reach level 1. As long as it does not crash, I can find ways to work around it. Thanks.

Original thread: https://forums.rpgmakerweb.com/threads/ace-error-while-using-himeworks-excel-exp-table.124273/