ValueMultiplier
A very simple class for working with value multipliers.
Properties
DEFAULT_MULTIPLIER
ConstantValueMultiplier.DEFAULT_MULTIPLIER:
1
Not Accessible
Constant, not accesible within ValueMultiplier
.
Functions
new
ValueMultiplier InstanceValueMultiplier.
new
(
identifier:
any
,
value:
number
,
baseValue:
number?
,
multiplier:
number?
) →
ValueMultiplier
Creates and returns a new value multiplier object. If multiplier
is not specified, it'll default to
ValueMultiplier.DEFAULT_MULTIPLIER.
local valueMultiplier = ValueMultiplier.new("Test", 16, 16)
print(valueMultiplier:updatedValue()) --> 16
valueMultiplier:setMultiplier(2)
print(valueMultiplier:updatedValue()) --> 32
WARNING
This method will throw an error if value
is nil
- it must be specified as a number.
fromIdentifier
Returns the value multiplier object of identifier identifier
, if there is any.
fromIdentifierPromise
Promisified version of ValueMultiplier.fromIdentifier.
observeForIdentifier
ValueMultiplier Instance
Observes for a new value multiplier created under the given identifier
. If one
already exists, then observer
will be called for it initially.
local valueMultiplier = ValueMultiplier.new("test", 0)
ValueMultiplier.observeForIdentifier("test", function(newValueMultiplier)
print(newValueMultiplier:baseValue())
end)
valueMultiplier:destroy()
ValueMultiplier.new("test", 5)
--> 0
--> 5
updatedValue
ValueMultiplier InstanceValueMultiplier:
updatedValue
(
) →
number
Returns the current value of the value multiplier adjusted based off of the multiplier and the base value. If no base value is set, then just the current value will be returned instead.
local valueMultiplier = ValueMultiplier.new(player, 16)
print(valueMultiplier.updatedValue()) --> 16, as no base value is set
valueMultiplier:setMultiplier(2)
print(valueMultiplier.updatedValue()) --> Still 16, as no base value is set
valueMultiplier:setBaseValue(16)
print(valueMultiplier:updatedValue()) --> 32
setValue
ValueMultiplier InstanceValueMultiplier:
setValue
(
newValue:
number
) →
(
)
Sets the value multiplier's value to newValue
.
setBaseValue
ValueMultiplier InstanceValueMultiplier:
setBaseValue
(
baseValue:
number
) →
(
)
Sets the value multiplier's base value to baseValue
.
setMultiplier
ValueMultiplier InstanceValueMultiplier:
setMultiplier
(
newMultiplier:
number
) →
(
)
Sets the value multiplier's multiplier to newMultiplier
.
multiplier
ValueMultiplier InstanceValueMultiplier:
multiplier
(
) →
number
Returns the multiplier set for the value multiplier.
baseValue
ValueMultiplier InstanceValueMultiplier:
baseValue
(
) →
number?
Returns the base value of the value multiplier.
destroy
ValueMultiplier InstanceValueMultiplier:
destroy
(
) →
(
)
Destroys the value multiplier and renders it unusable.