Adding stats to actors

Hello everyone! 

I would want to add some extra stats (mhp2, mmp2, atk2, def2, mat2, mdf2, agi2, luk2), each  bound to an actor id, so that I could call them with $game_actors[actor_id].atk2 . 

These stats would then be changed only using map events, so I just need to declare them (I think), the  problem is, I'm still not experienced enough with scripting, and I don't want to mess up the default scripts, could anyone please explain me how to do this?
There are already two scripts that can be used to this, depending on what exactly you want to do. I don't have the links ready, you have to search for them:


1) PK8's self data suite (the original links are dead, but in answer to a forum question on this forum PK8 posted a temporary working link)


This is more versatile when you use named self-variables on the actors


2) N.A.S.T.Y.s EXTRA Stat Script


Should be available on the master script list and be sufficient to add simple stats
Hi, thank you for your answer, I've tried using PK8's self data script, I assigned to an event this script

$game_actor_self_variable(1,mat2, 0, 0)But when I launch the game I keep getting this:

Spoiler
error.jpg


This is the script I'm using: 



I've tried changing that event's script call but keeps giving me different error messages ç_ç
Code:
=begin Self Data: Actors & Party 2 by PK8 Created: 9/16/2009 Modified: 5/14/2012 ────────────────────────────────────────────────────────────────────────────── ■ Table of Contents   ○ Introduction & Description                    - Line 16-22   ○ Features                                      - Line 24-26   ○ Changelog                                     - Line 28-41   ○ Methods Aliased                               - Line 43-44   ○ Thanks                                        - Line 46-54   ○ How to Use                                    - Line 56-154 ────────────────────────────────────────────────────────────────────────────── ■ Introduction & Description   This script is similar to that of RPG Maker's built in self-switches   feature, but instead of attaching switches to events, this script attaches   switches, variables, and metadata to your actors. Think about it. Your   actors have their own personal variables.      Perfect for setting up an actor's alignment, reputation and more. ────────────────────────────────────────────────────────────────────────────── ■ Features   Set switches/variables/metadata for Actors/Party Members through call script.   Get switches/variables/metadata for Actors/Party Members through call script. ────────────────────────────────────────────────────────────────────────────── ■ Changelog   v1 (9/16/2009): Initial release.   v2 (4/16/2012): Recoded. Actor & Party Self Switches, Self Variables,                   Self Parameters (now Metadata), Auto Self Switches/Variables/                   Metadata for Actor & Party have been combined.      (4/17/2012): Added case sensitivity options for IDs and a slew of                   shortcut options when setting up initial self data for                   actors.      (4/18/2012): Added array shortcuts for when setting up initial self data                   for actors.      (4/19/2012): Added a conditional for when party ids are set to nil in                   script calls.   v2.0.1(5/14/12):Patches up a mistake I did in the code which causes errors                   when nil is set as the party IDs value. ────────────────────────────────────────────────────────────────────────────── ■ Methods Aliased   o initialize of Game_Party class ────────────────────────────────────────────────────────────────────────────── ■ Thanks   Lowell: A few years prior to the making of this script, he offhandedly           mentioned something about giving personal variables to... I forgot           what, but it was for a project of his. And then the "scripting bug,"           as DerVVulfman calls it, bit me.   FoxDemonSoavi: If it weren't for her being a fan of the original scripts,                  I don't think I would've made this script much better than                  before.   Bravo2Kilo: For giving it a test run and finding some bugs. ────────────────────────────────────────────────────────────────────────────── ■ How to Use ┌──────────────────────────────────────────────────────────────────────────┐ │ ■ Script calls                                                           │ └──────────────────────────────────────────────────────────────────────────┘      Script calls for setting and getting Actor/Party Self Switches.       Set: actor_self_switch(actor_id, id, bool)  Get: actor_self_switch(actor_id, id)    * actor_id: Actor ID (Integers/ranges/arrays allowed. Nil = All) 1-based.    * id      : The name of your Actor Self Switch. Case sensitive!    * bool    : Set your Actor Self Switch on (true) or off (false).      Set: party_self_switch(party_id, id, bool)  Get: party_self_switch(party_id, id)    * party_id: Party Mem. ID (Integers/ranges/arrays allowed. nil=party) 0based    * id      : The name of your Party Member Self Switch. Case sensitive!    * bool    : Set your Party Member Self Switch on (true) or off (false).      Examples:  actor_self_switch(1, "A", true) <- Sets Actor 1's Self Switch "A" to true.  actor_self_switch(1, "A") <- Gets the value of Actor 1's Self Switch "A".    party_self_switch(0, "A", true) <- Set Party Mem. 1's Self Switch "A" to true.  party_self_switch(0, "A") <- Gets Party Member 1's Self Switch "A".        Script calls for setting and getting Actor/Party Self Variables.        Set: actor_self_variable(actor_id, id, value, oper)  Get: actor_self_variable(actor_id, id)    * actor_id: Actor ID (Integers/ranges/arrays allowed. Nil = All) 1-based.    * id      : The name of your Actor Self Variable. Case sensitive!    * value   : New value of your Actor Self Variable.    * oper    : 0: Equal / 1: Add / 2: Sub / 3: Multiply / 4: Divide / 5: Modulo      Set: party_self_variable(party_id, id, value, oper)  Get: party_self_variable(party_id, id)    * party_id: Party Mem. ID (Integers/ranges/arrays allowed. nil=party) 0based    * id      : The name of your Party Member Self Variable. Case sensitive!    * value   : New value of your Party Member Self Variable.    * oper    : 0: Equal / 1: Add / 2: Sub / 3: Multiply / 4: Divide / 5: Modulo          Script calls for setting and getting Actor/Party Self Metadata.        Set: actor_self_metadata(actor_id, id, value)  Get: actor_self_metadata(actor_id, id)    * actor_id: Actor ID (Integers/ranges/arrays allowed. Nil = All) 1-Based.    * id      : The name of your Actor Self Metadata. Case sensitive!    * value   : New value of your Actor Self Metadata.      Set: party_self_metadata(party_id, id, value)  Get: party_self_metadata(party_id, id)    * party_id: Party Mem. ID (Integers/ranges/arrays allowed. nil=party) 0Based    * id      : The name of your Party Member Self Metadata. Case sensitive!    * value   : New value of your Party Member Self Metadata.     ┌──────────────────────────────────────────────────────────────────────────┐ │ ■ Using Get script calls in conditional branches                         │ └──────────────────────────────────────────────────────────────────────────┘      Script calls to get a Actor/Party Member's Self Switch.       To do this, go to the conditional branch event command, click on the fourth tab, select Script and type either of these in the input form:    actor_self_switch(actor_id, id) == true    actor_self_switch(actor_id, id) == false    party_self_switch(party_id, id) == true    party_self_switch(party_id, id) == false          Script calls to get a Actor/Party Member's Self Variable.       To do this, go to the conditional branch event command, click on the fourth tab, select Script and type either of these in the input form:      actor_self_variable(actor_id, id) == value   <- Equal to.    actor_self_variable(actor_id, id) >= value   <- Greater than or Equal to.    actor_self_variable(actor_id, id) <= value   <- Less than or Equal to.    actor_self_variable(actor_id, id) > value    <- Greater than.    actor_self_variable(actor_id, id) < value    <- Less than.    actor_self_variable(actor_id, id) != value   <- Not Equal to.        party_self_variable(party_id, id) == value   <- Equal to.    party_self_variable(party_id, id) >= value   <- Greater than or Equal to.    party_self_variable(party_id, id) <= value   <- Less than or Equal to.    party_self_variable(party_id, id) > value    <- Greater than.    party_self_variable(party_id, id) < value    <- Less than.    party_self_variable(party_id, id) != value   <- Not Equal to.          Script calls to get a Actor/Party Member's Self Metadata.          actor_self_metadata(actor_id, id) == value   <- Equal to.    actor_self_metadata(actor_id, id) != value   <- Not Equal to.        party_self_metadata(party_id, id) == value   <- Equal to.    party_self_metadata(party_id, id) != value   <- Not Equal to.          These aren't the only conditionals you can use. There's plenty more, but      it's up to you and experiment with them. I recommend looking up the      RPG Maker help file on Strings, Integers, and more.      =end#==============================================================================# * Configuration#==============================================================================module SelfData  class Actor=begin    Setting shortcuts. There are four ways to set up your initial Actor/Party    self switches, variables, and metadata. Here's a few examples:        * Think of Type as Switches, Variables, or Metadata.        Type[[actor_id, id]] = value      * actor_id: Actor ID | id: Data name (Case sensitive)      This is the basic way of setting up initial data for your actors, but      there are shortcuts that can make setting up your initial self data less      time-consuming.          Type[[actor_id_start..actor_id_end, id]] = value      * actor_id_start: Actor ID Begin | actor_id_end: Actor ID End      * id: Data name (Case sensitive)      You can use a range to set from which actor ID to another would      set the value. Example: Type[[1..8, "Species"]] = "Human" sets      Actor IDs 1 to 8's "Species" ID to "Human".        Type[[[actor_ids], id]] = value      * actor_ids: Multiple Actor IDs (Ranges and integers allowed.)      * id: Data name (Case sensitive)      You can use as many Actor IDs as you want (from integers to ranges) to      set the value. Example: Type[[[1..3,6], "Gender"]] = "Male" sets      Actor IDs 1 to 3, and 6's "Gender" ID to "Male".        Type[[id]] = value / Type[id] = value      * id: Data name (Case sensitive)      This shortcut lets you attach the self data ID and its value to all      actors. Example: Type[["Species"]] = "Human" attaches the ID      "Species" to all actors and sets it to the value "Human".=end        #--------------------------------------------------------------------------    # * Do not modify    #--------------------------------------------------------------------------    Switches, Variables, Metadata = {}, {}, {}    #--------------------------------------------------------------------------    # General settings    #--------------------------------------------------------------------------    Sensitive_IDs = true      # Enable/disable case-sensitivity for IDs.    Sensitive_Values = true   # Enable/disable case-sensitivity for values.                              # * Keep in mind that turning these settings on                              #   can't help you with if conditionals.        #--------------------------------------------------------------------------    # * Set up Initial self switches for actors.    # Switches[[actor_id, id]] = value    #--------------------------------------------------------------------------    # Switches[[1, ""]] = true    #--------------------------------------------------------------------------    # * Set up Initial self variables for actors.    # Variables[[actor_id, id]] = value    #--------------------------------------------------------------------------    # Variables[[1, ""]] = 0        #--------------------------------------------------------------------------    # * Set up Initial self metadata for actors.    # Metadata[[actor_id, id]] = value    #--------------------------------------------------------------------------    # Metadata[[1, ""]] = ""  endend#==============================================================================# ** Game_Party#------------------------------------------------------------------------------#  This class handles the party. It includes information on amount of gold #  and items. Refer to "$game_party" for the instance of this class.#==============================================================================class Game_Party  attr_accessor :self_variables, :self_switches, :self_metadata  #--------------------------------------------------------------------------  # * Alias Listings  #--------------------------------------------------------------------------  unless method_defined?(:pk8_selfdata_initialize)    alias_method(:pk8_selfdata_initialize, :initialize)  end  #--------------------------------------------------------------------------  # * Object Initialization  #--------------------------------------------------------------------------  def initialize    pk8_selfdata_initialize    @self_variables = Game_Party::SelfVariables.new    @self_switches = Game_Party::SelfSwitches.new    @self_metadata = Game_Party::SelfMetadata.new  endend#==============================================================================# ** Game_Party::SelfSwitches#------------------------------------------------------------------------------#  This handles self switches for actors and party members.#  The instance of this class is referenced by $game_party.self_switches.#==============================================================================class Game_Party::SelfSwitches  #--------------------------------------------------------------------------  # * Object Initialization  #--------------------------------------------------------------------------  def initialize    @data = {}    SelfData::Actor::Switches.each { |k,v|      if k.size == 2  # If specified Switch setting has 2 items in array.        if SelfData::Actor::Sensitive_IDs == false and k[1].is_a?(String)          k[1] = k[1].downcase        end        if k[0].is_a?(Range)          for i in k[0]; @data[[i, k[1]]] = v; end        elsif k[0].is_a?(Integer)            @data[k] = v        elsif k[0].is_a?(Array)          for i in 0..k[0].size - 1            if k[0][i].is_a?(Integer)              key = [k[0][i].id, k[1]]              @data[key] = v            elsif k[0][i].is_a?(Range)              for ir in k[0][i]                key = [ir, k[1]]                @data[key] = v              end            end          end        end      else  # If specified Switch setting has 1 item in array.        if k.is_a?(Array)          if SelfData::Actor::Sensitive_IDs == false and k[0].is_a?(String)            k[0] = k[0].downcase          end          for i in 0..$data_actors.size - 1; @data[[i, k[0]]] = v; end        else          if SelfData::Actor::Sensitive_IDs == false and k.is_a?(String)            k = k.downcase          end          for i in 0..$data_actors.size - 1; @data[[i, k]] = v; end        end      end    }  end  #--------------------------------------------------------------------------  # * Get Self Switch of Actor  #     key : key  #--------------------------------------------------------------------------  def [](key)    if SelfData::Actor::Sensitive_IDs == false and key[1].is_a?(String)      key[1] = key[1].downcase    end    return @data[key] == true ? true : false  end  #--------------------------------------------------------------------------  # * Set Self Switch of Actor  #     key   : key  #     value : ON (true) / OFF (false)  #--------------------------------------------------------------------------  def []=(key, value)    if SelfData::Actor::Sensitive_IDs == false and key[1].is_a?(String)      key[1] = key[1].downcase    end    @data[key] = value  endend#==============================================================================# ** Game_Party::SelfVariables#------------------------------------------------------------------------------#  This handles self variables for actors and party members. The instance of#  this class is referenced by $game_party.self_variables.#==============================================================================class Game_Party::SelfVariables  #--------------------------------------------------------------------------  # * Object Initialization  #--------------------------------------------------------------------------  def initialize    @data = {}    SelfData::Actor::Variables.each { |k,v|      if k.size == 2  # If specified Variable setting has 2 items in array.        if SelfData::Actor::Sensitive_IDs == false and k[1].is_a?(String)          k[1] = k[1].downcase        end        if k[0].is_a?(Range)          for i in k[0]; @data[[i, k[1]]] = v; end        elsif k[0].is_a?(Integer)            @data[k] = v        elsif k[0].is_a?(Array)          for i in 0..k[0].size - 1            if k[0][i].is_a?(Integer)              key = [k[0][i].id, k[1]]              @data[key] = v            elsif k[0][i].is_a?(Range)              for ir in k[0][i]                key = [ir, k[1]]                @data[key] = v              end            end          end        end      else  # If specified Variable setting has 1 item in array.        if k.is_a?(Array)          if SelfData::Actor::Sensitive_IDs == false and k[0].is_a?(String)            k[0] = k[0].downcase          end          for i in 0..$data_actors.size - 1; @data[[i, k[0]]] = v; end        else          if SelfData::Actor::Sensitive_IDs == false and k.is_a?(String)            k = k.downcase          end          for i in 0..$data_actors.size - 1; @data[[i, k]] = v; end        end      end    }  end  #--------------------------------------------------------------------------  # * Get Self Variable of Actor  #     key : key  #--------------------------------------------------------------------------  def [](key)    if SelfData::Actor::Sensitive_IDs == false and key[1].is_a?(String)      key[1] = key[1].downcase    end    if @data[key] == nil      return 0    else      return @data[key]    end  end  #--------------------------------------------------------------------------  # * Set Self Variable of Actor  #     key   : key  #     value : value  #--------------------------------------------------------------------------  def []=(key, value)    if SelfData::Actor::Sensitive_IDs == false and key[1].is_a?(String)      key[1] = key[1].downcase    end    @data[key] = value  endend#==============================================================================# ** Game_Party::SelfMetadata#------------------------------------------------------------------------------#  This handles self metadata for actors and party members.#  The instance of this class is referenced by $game_party.self_metadata.#==============================================================================class Game_Party::SelfMetadata  #--------------------------------------------------------------------------  # * Object Initialization  #--------------------------------------------------------------------------  def initialize    @data = {}    SelfData::Actor::Metadata.each { |k,v|      if SelfData::Actor::Sensitive_Values == false and v.is_a?(String)        v = v.downcase      end      if k.size == 2  # If specified Metadata setting has 2 items in array.        if k[0].is_a?(Range)          for i in k[0]; @data[[i, k[1]]] = v; end        elsif k[0].is_a?(Integer)            @data[k] = v        elsif k[0].is_a?(Array)          for i in 0..k[0].size - 1            if k[0][i].is_a?(Integer)              key = [k[0][i].id, k[1]]              @data[key] = v            elsif k[0][i].is_a?(Range)              for ir in k[0][i]                key = [ir, k[1]]                @data[key] = v              end            end          end        end      else  # If specified Metadata setting has 1 item in array.        if k.is_a?(Array)          if SelfData::Actor::Sensitive_IDs == false and k[0].is_a?(String)            k[0] = k[0].downcase          end          for i in 0..$data_actors.size - 1; @data[[i, k[0]]] = v; end        else          if SelfData::Actor::Sensitive_IDs == false and k.is_a?(String)            k = k.downcase          end          for i in 0..$data_actors.size - 1; @data[[i, k]] = v; end        end      end    }  end  #--------------------------------------------------------------------------  # * Get Self Metadata  #     key : key  #--------------------------------------------------------------------------  def [](key)    if SelfData::Actor::Sensitive_IDs == false and key[1].is_a?(String)      key[1] = key[1].downcase    end    return @data[key] if @data[key] != nil  end  #--------------------------------------------------------------------------  # * Set Self Metadata  #     key   : key  #     value : key's value  #--------------------------------------------------------------------------  def []=(key, value)    if SelfData::Actor::Sensitive_Values == false and value.is_a?(String)      value = value.downcase    end    if SelfData::Actor::Sensitive_IDs == false and key[1].is_a?(String)      key[1] = key[1].downcase    end    @data[key] = value  endend#==============================================================================# ** Game_Interpreter#------------------------------------------------------------------------------#  An interpreter for executing event commands. This class is used within the# Game_Map, Game_Troop, and Game_Event classes.#==============================================================================class Game_Interpreter  #--------------------------------------------------------------------------  # * Control Actor Self Switch  #--------------------------------------------------------------------------  def actor_self_switch(actor_id, id, bool = nil)    if actor_id.is_a?(Integer)      if $data_actors[actor_id].id > 0 and $data_actors[actor_id] != nil        key = [$data_actors[actor_id].id, id]        if bool != nil  # Sets          $game_party.self_switches[key] = bool        else            # Gets          return $game_party.self_switches[key]        end      end    elsif actor_id.is_a?(Range)      array = [] if bool == nil      for i in actor_id        if $data_actors[i].id > 0 and $data_actors[i] != nil          key = [$data_actors[i].id, id]          if bool != nil  # Sets            $game_party.self_switches[key] = bool          else            # Gets            array.push($game_party.self_switches[key])          end        end      end      return array if bool == nil    elsif actor_id.is_a?(Array)      array = [] if bool == nil      for i in 0..actor_id.size - 1        if $data_actors[actor_id[i]].id > 0 and $data_actors[actor_id[i]] != nil          if actor_id[i].is_a?(Integer)            key = [$data_actors[actor_id[i]].id, id]            if bool != nil  # Sets              $game_party.self_switches[key] = bool            else            # Gets              array.push($game_party.self_switches[key])            end          elsif actor_id[i].is_a?(Range)            for ir in actor_id[i]              key = [$data_actors[ir].id, id]              if bool != nil  # Sets                $game_party.self_switches[key] = bool              else            # Gets                array.push($game_party.self_switches[key])              end            end          end        end      end      return array if bool == nil    elsif actor_id == nil      array = [] if bool == nil      for i in 1..$data_actors.size - 1        if bool != nil          $game_party.self_switches[[i, id]] = bool        else          array.push($game_party.self_switches[[i, id]])        end      end      return array if bool == nil    end    $game_map.need_refresh = true    return true  end  #--------------------------------------------------------------------------  # * Control Actor Self Variable  #--------------------------------------------------------------------------  def actor_self_variable(actor_id, id, value = nil, oper = nil)    if actor_id.is_a?(Integer)      if $data_actors[actor_id].id > 0 and $data_actors[actor_id] != nil        key = [$data_actors[actor_id].id, id]        if value != nil # Sets          case oper          when nil, 0, 'equal', 'set', '='                     # Setting            $game_party.self_variables[key] = value          when 1, 'add', '+'                                   # Adding            $game_party.self_variables[key] += value          when 2, 'sub', 'subtract', '-'                       # Subtracting            $game_party.self_variables[key] -= value          when 3, 'mul', 'multiply', 'x', '*'                  # Multiplying            $game_party.self_variables[key] *= value          when 4, 'div', 'divide', '/'                         # Dividing            $game_party.self_variables[key] /= value if value != 0          when 5, 'mod', 'modulo', 'modular', '%'              # Modulating            $game_party.self_variables[key] %= value if value != 0          end        else            # Gets          return $game_party.self_variables[key]        end      end    elsif actor_id.is_a?(Range)      array = [] if value == nil      for i in actor_id        if $data_actors[i].id > 0 and $data_actors[i] != nil          key = [$data_actors[i].id, id]          if value != nil  # Sets            case oper            when nil, 0, 'equal', 'set', '='                     # Setting              $game_party.self_variables[key] = value            when 1, 'add', '+'                                   # Adding              $game_party.self_variables[key] += value            when 2, 'sub', 'subtract', '-'                       # Subtracting              $game_party.self_variables[key] -= value            when 3, 'mul', 'multiply', 'x', '*'                  # Multiplying              $game_party.self_variables[key] *= value            when 4, 'div', 'divide', '/'                         # Dividing              $game_party.self_variables[key] /= value if value != 0            when 5, 'mod', 'modulo', 'modular', '%'              # Modulating              $game_party.self_variables[key] %= value if value != 0            end          else             # Gets            array.push($game_party.self_variables[key])          end        end      end      return array if value == nil    elsif actor_id.is_a?(Array)      array = [] if value == nil      for i in 0..actor_id.size - 1        if $data_actors[actor_id[i]].id > 0 and $data_actors[actor_id[i]] != nil          if actor_id[i].is_a?(Integer)            key = [$data_actors[actor_id[i]].id, id]            if value != nil # Sets              case oper              when nil, 0, 'equal', 'set', '='                     # Setting                $game_party.self_variables[key] = value              when 1, 'add', '+'                                   # Adding                $game_party.self_variables[key] += value              when 2, 'sub', 'subtract', '-'                       # Subtracting                $game_party.self_variables[key] -= value              when 3, 'mul', 'multiply', 'x', '*'                  # Multiplying                $game_party.self_variables[key] *= value              when 4, 'div', 'divide', '/'                         # Dividing                $game_party.self_variables[key] /= value if value != 0              when 5, 'mod', 'modulo', 'modular', '%'              # Modulating                $game_party.self_variables[key] %= value if value != 0              end            else            # Gets              array.push($game_party.self_variables[key])            end          elsif actor_id[i].is_a?(Range)            for ir in actor_id[i]              key = [$data_actors[ir].id, id]              if value != nil # Sets                case oper                when nil, 0, 'equal', 'set', '='                   # Setting                  $game_party.self_variables[key] = value                when 1, 'add', '+'                                 # Adding                  $game_party.self_variables[key] += value                when 2, 'sub', 'subtract', '-'                     # Subtracting                  $game_party.self_variables[key] -= value                when 3, 'mul', 'multiply', 'x', '*'                # Multiplying                  $game_party.self_variables[key] *= value                when 4, 'div', 'divide', '/'                       # Dividing                  $game_party.self_variables[key] /= value if value != 0                when 5, 'mod', 'modulo', 'modular', '%'            # Modulating                  $game_party.self_variables[key] %= value if value != 0                end              else            # Gets                array.push($game_party.self_variables[key])              end            end          end        end      end      return array if value == nil    elsif actor_id == nil      array = [] if value == nil      for i in 1..$data_actors.size - 1        if value != nil          case oper          when nil, 0, 'equal', 'set', '='                   # Setting            $game_party.self_variables[[i, id]] = value          when 1, 'add', '+'                                 # Adding            $game_party.self_variables[[i, id]] += value          when 2, 'sub', 'subtract', '-'                     # Subtracting            $game_party.self_variables[[i, id]] -= value          when 3, 'mul', 'multiply', 'x', '*'                # Multiplying            $game_party.self_variables[[i, id]] *= value          when 4, 'div', 'divide', '/'                       # Dividing            $game_party.self_variables[[i, id]] /= value if value != 0          when 5, 'mod', 'modulo', 'modular', '%'            # Modulating            $game_party.self_variables[[i, id]] %= value if value != 0          end        else          array.push($game_party.self_variables[[i, id]])        end      end      return array if value == nil    end    $game_map.need_refresh = true    return true  end  #--------------------------------------------------------------------------  # * Control Actor Self Metadata  #--------------------------------------------------------------------------  def actor_self_metadata(actor_id, id, value = nil)    if actor_id.is_a?(Integer)      if $data_actors[actor_id].id > 0 and $data_actors[actor_id] != nil        key = [$data_actors[actor_id].id, id]        if value != nil  # Sets          $game_party.self_metadata[key] = value        else            # Gets          return $game_party.self_metadata[key]        end      end    elsif actor_id.is_a?(Range)      array = [] if value == nil      for i in actor_id        if $data_actors[i].id > 0 and $data_actors[i] != nil          key = [$data_actors[i].id, id]          if value != nil  # Sets            $game_party.self_metadata[key] = value          else            # Gets            array.push($game_party.self_metadata[key])          end        end      end      return array if value == nil    elsif actor_id.is_a?(Array)      array = [] if value == nil      for i in 0..actor_id.size - 1        if ($data_actors[actor_id[i]].id > 0 and              $data_actors[actor_id[i]] != nil)          if actor_id[i].is_a?(Integer)            key = [$data_actors[actor_id[i]].id, id]            if value != nil  # Sets              $game_party.self_metadata[key] = value            else            # Gets              array.push($game_party.self_metadata[key])            end          elsif actor_id[i].is_a?(Range)            for ir in actor_id[i]              key = [$data_actors[ir].id, id]              if value != nil  # Sets                $game_party.self_metadata[key] = value              else            # Gets                array.push($game_party.self_metadata[key])              end            end          end        end      end      return array if value == nil    elsif actor_id == nil      array = [] if value == nil      for i in 1..$data_actors.size - 1        if value != nil          $game_party.self_metadata[[i, id]] = value        else          array.push($game_party.self_metadata[[i, id]])        end      end      return array if value == nil    end    $game_map.need_refresh = true    return true  end  #--------------------------------------------------------------------------  # * Control Party Member Self Switch  #--------------------------------------------------------------------------  def party_self_switch(party_id, id, bool = nil)    if party_id != nil      actor_id = $game_party.members[party_id].id    else      actor_id = []      for i in 0...$game_party.members.size        actor_id.push($game_party.members[i].id)        actor_self_switch(actor_id[i], id, bool)      end    end    return actor_self_switch(actor_id, id, bool)  end  #--------------------------------------------------------------------------  # * Control Party Member Self Variable  #--------------------------------------------------------------------------  def party_self_variable(party_id, id, value = nil, oper = nil)    if party_id != nil      actor_id = $game_party.members[party_id].id    else      actor_id = []      for i in 0...$game_party.members.size        actor_id.push($game_party.members[i].id)        actor_self_variable(actor_id[i], id, value, oper)      end    end    return actor_self_variable(actor_id, id, value, oper)  end  #--------------------------------------------------------------------------  # * Control Party Member Self Metadata  #--------------------------------------------------------------------------  def party_self_metadata(party_id, id, value = nil)    if party_id != nil      actor_id = $game_party.members[party_id].id    else      actor_id = []      for i in 0...$game_party.members.size        actor_id.push($game_party.members[i].id)        actor_self_metadata(actor_id[i], id, value)      end    end    return actor_self_metadata(actor_id, id, value)  endend 
You need to use the script calls exactly as given - nowhere in the script's description you are told to put a $game in front of the commands.

here is the correct command:

Code:
actor_self_variable(1,'mat2',0,0)
This will define a self-variable named mat2 on the first actor in the party and set its value to zero
Oh I feel so stupid, I forgot the apostrophes, thank you for your help  🙂

Original thread: https://forums.rpgmakerweb.com/threads/adding-stats-to-actors.37471/