RM XP - How to make new stats

So I'm attempting to make new stats, and I can't find anywhere to learn that information. One "stat" I made was in Game_Battler 1

SOLUTION FOUND!

Spoiler: Solution that was found
So, although you use $data_enemies command to get the stats of specific enemies, you can't use $data_actors. The correct command is $game_actors. The reason it said "atb=" is undefined is because the reason it worked for other stats is because they had a method for themselves like:

Code:
#--------------------------------------------------------------------------
  # * Set Intelligence (INT)
  #     int : new Intelligence (INT)
  #--------------------------------------------------------------------------
  def int=(int)
    @int_plus += int - self.int
    @int_plus = [[@int_plus, -999].max, 999].min
  end

def int=(int) is why "$game_actors.int =" can work. So I simply did the same for mine.
Code:
#--------------------------------------------------------------------------
  # * Set Charge Bar (CBR)
  #     int : new Charge Bar (CBR)
  #--------------------------------------------------------------------------
  def atb=(atb)
    @atb_plus += atb - self.atb
    @atb_plus = [[@atb_plus, 25].max, 500].min
  end

You will need to add a "_plus" equivalent of your stat (in the same script, game battler 1) so it'll reset to 0 when it's called again so nothing janky happens with your stats.I put it with the rest of the "_plus" which is here:

Code:
def initialize
    @battler_name = ""
    @battler_hue = 0
    @hp = 0
    @sp = 0
    @states = []
    @states_turn = {}
    @maxhp_plus = 0
    @maxsp_plus = 0
    @str_plus = 0
    @dex_plus = 0
    @agi_plus = 0
    @int_plus = 0
    @atb_plus = 0
    @hidden = false
    @immortal = false
    @damage_pop = false
    @damage = nil
    @critical = false
    @animation_id = 0
    @animation_hit = false
    @white_flash = false
    @blink = false
    @current_action = Game_BattleAction.new
  end

Spoiler: Problem
Code:
#--------------------------------------------------------------------------
  # * Get Attack Speed (ATB)
  #--------------------------------------------------------------------------
  def atb
    #n = (agi * 2) - (base_pdef * 2)
    n = agi
    n = [[Integer(n), 25].max, 500].min
    return n
  end

I referenced it in Window_Base which then allowed me to reference it in Window_Status
Code:
  #--------------------------------------------------------------------------
  # * Draw Parameter
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     type  : parameter type (0-6)
  #--------------------------------------------------------------------------
  def draw_actor_parameter(actor, x, y, type)
    case type
    when 0
      parameter_name = $data_system.words.atk
      parameter_value = actor.atk
    when 1
      parameter_name = $data_system.words.pdef
      parameter_value = actor.pdef
    when 2
      parameter_name = $data_system.words.mdef
      parameter_value = actor.mdef
    when 3
      parameter_name = $data_system.words.str
      parameter_value = actor.str
    when 4
      parameter_name = $data_system.words.dex
      parameter_value = actor.dex
    when 5
      parameter_name = $data_system.words.agi
      parameter_value = actor.agi
    when 6
      parameter_name = $data_system.words.int
      parameter_value = actor.int
    when 7
      parameter_name = "ATB"
      parameter_value = actor.atb
    end

In Window_Status
Code:
draw_actor_parameter(@actor, 100, 192, 7)


It's just "agi" now but that's because I was testing some things and needed ATB to be a set number with minimal intervention. What I'm aiming for is to be able to call it and change it via script calls. I got it to appear in the status screen, battle screen, etc. The script call I'm specifically trying to use is $data_actors as, of recent, I found out I could permanently change the stats of an enemy mid-game forever so after doing stuff like $data_enemies[1].name = "BOB", I tried to call for atb (for actors) and the error came and for the stats I'm planning to add, this is my only way to change it since I can't change it through events.

This is the error:
Picture4.png


And I don't know where I have to go to define it as a method :/
Thread closed

Original thread: https://forums.rpgmakerweb.com/threads/rm-xp-how-to-make-new-stats.117840/