Stat Modifier

The stat modifier object represents a single single stat modifier. Such as + 5 or + 10% or = 4.5. The modifier is not linked to a stat until it is placed into a stat modifiers collection. @see am.stat_modifiers
Return to Index
new ( )
new ( number value , string type , boolean magical = true )
__gc ( )
__eq ( am.stat_modifier modifiers ) -> ( boolean )
value ( ) -> ( number )
value ( number value ) -> ( am.stat_modifier )
type ( ) -> ( string )
type ( string type ) -> ( am.stat_modifier )
magical ( ) -> ( boolean )
magical ( boolean magical ) -> ( am.stat_modifier )
new ( )
Creates a new empty stat modifier object.
new ( number value , string type , boolean magical = true )
Creates a new stat modifier object with the given parameters. The value of this modifier is used in the context of the type of modification. This is the list of each modifier type:
  • = : Sets the stat to the given value. This mod is applied first.
  • * : Multiplies the stat by the given value. This mod is applied second.
  • + : Adds the given value directly onto the stat, this value can be negative. This mod is applied third.
Parameters:
number value : The value of this modifier.
string type : The stat modifier type.
boolean magical = true : This currently does not change the behaviour of the modifier, however it does allow the UI to show the origin of this mod better.
__gc ( )
Deletes the stat modifier object.
__eq ( am.stat_modifier modifiers ) -> ( boolean )
Compares this stat modifier with the given one. Unlike many of the other Lua objects, this comparison will check if the objects are equivalent.
 mod1 = am.stat_modifier.new(5, "+")
 mod2 = am.stat_modifier.new(5, "+")
 mod3 = am.stat_modifier.new(5, "*")
 am_log("Mod 1 == Mod 2? " .. (mod1 == mod2)) -- Output "Mod 1 == Mod 2? true"
 am_log("Mod 1 == Mod 3? " .. (mod1 == mod3)) -- Output "Mod 1 == Mod 3? false"
 am_log("Mod 2 == Mod 3? " .. (mod2 == mod2)) -- Output "Mod 2 == Mod 3? false"
Parameters:
am.stat_modifier modifiers : The other stat modifiers object to compare with.
Returns:
boolean : True if they are the same stat modifiers object.
value ( ) -> ( number )
Returns the value of this stat modifier.
Returns:
number : The stat modifier value.
value ( number value ) -> ( am.stat_modifier )
Sets the stat modifier value.
Parameters:
number value : The new value for this modifier.
Returns:
am.stat_modifier : This
type ( ) -> ( string )
Returns the type of this stat modifier.
Returns:
string : The stat modifier type.
type ( string type ) -> ( am.stat_modifier )
Sets the stat modifier type. This is the list of each modifier type:
  • = : Sets the stat to the given value. This mod is applied first.
  • * : Multiplies the stat by the given value. This mod is applied second.
  • + : Adds the given value directly onto the stat, this value can be negative. This mod is applied third.
Parameters:
string type : The new type for this modifier.
Returns:
am.stat_modifier : This
magical ( ) -> ( boolean )
Returns the magical nature of this stat modifier.
Returns:
boolean : True if this is a magical mod.
magical ( boolean magical ) -> ( am.stat_modifier )
Sets if modifier is magical in nature.
Parameters:
boolean magical : The new magical flag for this modifier.
Returns:
am.stat_modifier : This