Skip to main content

ValueMultiplier

A very simple class for working with value multipliers.

Properties

DEFAULT_MULTIPLIER

Constant
ValueMultiplier.DEFAULT_MULTIPLIER: 1
Not Accessible

Constant, not accesible within ValueMultiplier.

Functions

new

ValueMultiplier Instance
ValueMultiplier.new(
identifierany,
valuenumber,
baseValuenumber?,
multipliernumber?
) → 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

ValueMultiplier.fromIdentifier(identifierany) → ValueMultiplier?

Returns the value multiplier object of identifier identifier, if there is any.

fromIdentifierPromise

ValueMultiplier.fromIdentifierPromise(identifierany) → Promise<ValueMultiplier>

Promisified version of ValueMultiplier.fromIdentifier.

observeForIdentifier

ValueMultiplier Instance
ValueMultiplier.observeForIdentifier(
identifierany,
observer(newValueMultiplierValueMultiplier) → ()
) → Connection

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 Instance
ValueMultiplier: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 Instance
ValueMultiplier:setValue(newValuenumber) → ()

Sets the value multiplier's value to newValue.

setBaseValue

ValueMultiplier Instance
ValueMultiplier:setBaseValue(baseValuenumber) → ()

Sets the value multiplier's base value to baseValue.

setMultiplier

ValueMultiplier Instance
ValueMultiplier:setMultiplier(newMultipliernumber) → ()

Sets the value multiplier's multiplier to newMultiplier.

multiplier

ValueMultiplier Instance
ValueMultiplier:multiplier() → number

Returns the multiplier set for the value multiplier.

baseValue

ValueMultiplier Instance
ValueMultiplier:baseValue() → number?

Returns the base value of the value multiplier.

destroy

ValueMultiplier Instance
ValueMultiplier:destroy() → ()

Destroys the value multiplier and renders it unusable.

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": " \n\nCreates and returns a new value multiplier object. If `multiplier` is not specified, it'll default to\n[ValueMultiplier.DEFAULT_MULTIPLIER].\n\n```lua\nlocal valueMultiplier = ValueMultiplier.new(\"Test\", 16, 16)\n\nprint(valueMultiplier:updatedValue()) --> 16\nvalueMultiplier:setMultiplier(2)\nprint(valueMultiplier:updatedValue()) --> 32\n```\n\n:::warning\nThis method will throw an error if `value` is `nil` - it must be specified as a number.\n:::",
            "params": [
                {
                    "name": "identifier",
                    "desc": "",
                    "lua_type": "any"
                },
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "baseValue",
                    "desc": "",
                    "lua_type": "number?"
                },
                {
                    "name": "multiplier",
                    "desc": "",
                    "lua_type": "number?\n"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "ValueMultiplier"
                }
            ],
            "function_type": "static",
            "tags": [
                "ValueMultiplier Instance"
            ],
            "source": {
                "line": 48,
                "path": "src/ValueMultiplier/init.luau"
            }
        },
        {
            "name": "fromIdentifier",
            "desc": " \nReturns the value multiplier object of identifier `identifier`, if there is any.",
            "params": [
                {
                    "name": "identifier",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "ValueMultiplier?\n"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 71,
                "path": "src/ValueMultiplier/init.luau"
            }
        },
        {
            "name": "fromIdentifierPromise",
            "desc": " \nPromisified version of [ValueMultiplier.fromIdentifier].",
            "params": [
                {
                    "name": "identifier",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<ValueMultiplier>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 81,
                "path": "src/ValueMultiplier/init.luau"
            }
        },
        {
            "name": "observeForIdentifier",
            "desc": " \n\nObserves for a new value multiplier created under the given `identifier`. If one\nalready exists, then `observer` will be called for it initially.\n\n```lua\nlocal valueMultiplier = ValueMultiplier.new(\"test\", 0)\n\nValueMultiplier.observeForIdentifier(\"test\", function(newValueMultiplier)\n\tprint(newValueMultiplier:baseValue())\nend)\n\nvalueMultiplier:destroy()\nValueMultiplier.new(\"test\", 5)\n\n--> 0\n--> 5\n```",
            "params": [
                {
                    "name": "identifier",
                    "desc": "",
                    "lua_type": "any"
                },
                {
                    "name": "observer",
                    "desc": "",
                    "lua_type": "(newValueMultiplier: ValueMultiplier) -> ()\n"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Connection"
                }
            ],
            "function_type": "static",
            "tags": [
                "ValueMultiplier Instance"
            ],
            "source": {
                "line": 113,
                "path": "src/ValueMultiplier/init.luau"
            }
        },
        {
            "name": "updatedValue",
            "desc": " \n\nReturns the current value of the value multiplier adjusted based off of the multiplier and\nthe base value. If no base value is set, then just the current value will be returned instead.\n\n```lua\n\nlocal valueMultiplier = ValueMultiplier.new(player, 16)\n\nprint(valueMultiplier.updatedValue()) --> 16, as no base value is set\n\nvalueMultiplier:setMultiplier(2)\n\nprint(valueMultiplier.updatedValue()) --> Still 16, as no base value is set\nvalueMultiplier:setBaseValue(16)\nprint(valueMultiplier:updatedValue()) --> 32\n```",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "number\n"
                }
            ],
            "function_type": "method",
            "tags": [
                "ValueMultiplier Instance"
            ],
            "source": {
                "line": 152,
                "path": "src/ValueMultiplier/init.luau"
            }
        },
        {
            "name": "setValue",
            "desc": " \n\nSets the value multiplier's value to `newValue`.",
            "params": [
                {
                    "name": "newValue",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [],
            "function_type": "method",
            "tags": [
                "ValueMultiplier Instance"
            ],
            "source": {
                "line": 170,
                "path": "src/ValueMultiplier/init.luau"
            }
        },
        {
            "name": "setBaseValue",
            "desc": " \n\nSets the value multiplier's base value to `baseValue`.",
            "params": [
                {
                    "name": "baseValue",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [],
            "function_type": "method",
            "tags": [
                "ValueMultiplier Instance"
            ],
            "source": {
                "line": 180,
                "path": "src/ValueMultiplier/init.luau"
            }
        },
        {
            "name": "setMultiplier",
            "desc": " \n\nSets the value multiplier's multiplier to `newMultiplier`.",
            "params": [
                {
                    "name": "newMultiplier",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [],
            "function_type": "method",
            "tags": [
                "ValueMultiplier Instance"
            ],
            "source": {
                "line": 190,
                "path": "src/ValueMultiplier/init.luau"
            }
        },
        {
            "name": "multiplier",
            "desc": " \n\nReturns the multiplier set for the value multiplier.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "number\n"
                }
            ],
            "function_type": "method",
            "tags": [
                "ValueMultiplier Instance"
            ],
            "source": {
                "line": 200,
                "path": "src/ValueMultiplier/init.luau"
            }
        },
        {
            "name": "baseValue",
            "desc": " \n\nReturns the base value of the value multiplier.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "number?\n"
                }
            ],
            "function_type": "method",
            "tags": [
                "ValueMultiplier Instance"
            ],
            "source": {
                "line": 210,
                "path": "src/ValueMultiplier/init.luau"
            }
        },
        {
            "name": "destroy",
            "desc": " \n\nDestroys the value multiplier and renders it unusable.",
            "params": [],
            "returns": [],
            "function_type": "method",
            "tags": [
                "ValueMultiplier Instance"
            ],
            "source": {
                "line": 220,
                "path": "src/ValueMultiplier/init.luau"
            }
        }
    ],
    "properties": [
        {
            "name": "DEFAULT_MULTIPLIER",
            "desc": " \n\n:::warning Not Accessible\nConstant, not accesible within `ValueMultiplier`.\n:::",
            "lua_type": "1",
            "tags": [
                "Constant"
            ],
            "source": {
                "line": 16,
                "path": "src/ValueMultiplier/init.luau"
            }
        }
    ],
    "types": [],
    "name": "ValueMultiplier",
    "desc": " \n\nA very simple class for working with value multipliers.",
    "source": {
        "line": 6,
        "path": "src/ValueMultiplier/init.luau"
    }
}