Skip to main content

DropletUtil

Internal utility functions for droplets

Types

WeightedArray<T>

type WeightedArray<T> = {{
Weightnumber,
ValueT
}}

A table of values with weights. The weights are used to calculate the probability of a value being chosen. The weights do not need to add up to 1. See ProbabilityDistributor for more information.

NumOrRange

type NumOrRange = number | NumberRange

NumOrRangeOrWeightedArray

type NumOrRangeOrWeightedArray = NumOrRange | WeightedArray<NumOrRange>

ResourceTypeData

interface ResourceTypeData {
Defaultstable
SetupDroplet(dropletDroplet) → any?
OnRenderUpdate((
dropletDroplet,
renderTimenumber
) → (CFrame?))?
OnDropletTimeout((dropletDroplet) → ())?
OnClientClaim((
playerWhoCollectedPlayer,
dropletDroplet
) → ())?
OnClientCollect((
playerWhoCollectedPlayer,
dropletDroplet
) → ())?
OnServerCollect((
playerWhoCollectedPlayer,
valueany,
metadataany
) → ())?
}
  • [Defaults] is a table of default values for the droplet. This can be left empty. The values in this table are used to fill in any missing values in the ResourceSpawnData when a droplet is spawned as well as overriding certain behaviors internall for things like magnetization.

  • [SetupDroplet] is called when a new droplet is created. Use this to setup your visuals and any variables you need to keep track of. All parts within this should be Anchored = false, CanCollide = false, and Massless = true. The return value of this function can be accessed via Droplet:GetSetupData()

  • [OnRenderUpdate] is called every frame that the droplet is within render range of the LocalPlayer's Camera. Use this to update the visuals of your droplet. The return value, if one is given, must be a CFrame and is used for offsetting the droplet.

  • [OnDropletTimeout] is called when the droplet times out. Use this to perform/cleanup any visual effects you may have.

  • [OnClientClaim] is called when the server acknowledges that the droplet has been claimed.

  • [OnClientCollect] is called when the droplet hits the player and is considered collected. It should be used for collection effects and other client side things.

  • [OnServerCollect] is called once the server is informed by a client that the droplet has been collected. This is where you should perform any server side logic like actually giving things like Money or Exp.

ResourceSpawnData

interface ResourceSpawnData {
ResourceTypestring--

The registered name of the resource type

Valueany | NumOrRangeOrWeightedArray--

The value of the droplet

Metadataany?--

The metadata of the droplet

SpawnLocationVector3 | CFrame | PVInstance--

The location to spawn the droplet

CollectorModeCollectorMode?--

The behavior of how the droplet is claimed

PlayerTargetsPlayer | {Player}?--

The players that can collect the droplet

LifeTimeNumOrRange?--

The time before the droplet dissapears

CountNumOrRangeOrWeightedArray?--

The number of droplets to spawn

EjectionDurationNumOrRangeOrWeightedArray?--

The time it takes to spew out all the droplets

EjectionHorizontalVelocityNumOrRangeOrWeightedArray?--

The horizontal velocity of the droplets when they are ejected

EjectionVerticalVelocityNumOrRangeOrWeightedArray?--

The vertical velocity of the droplets when they are ejected

}
Special Behaviors

Any index that takes a NumOrRangeOrWeightedArray will be parsed and calculated ahead of time internally so that the client and server are synced. For example, if you pass in a NumberRange for Value, the server will calculate a random decimal number between the min and max, this number would then be accessed by Droplet:GetValue() on the client.

CollectorMode

type CollectorMode = "MultiCollector" | "SingleCollector"

The behavior of how the droplet is claimed.

  • MultiCollector - Many players can collect this droplet, each has their own individual instance

  • SingleCollector - Only one player can collect this droplet

Properties

Enums

DropletUtil.Enums: {CollectorMode{
MultiCollectorCollectorMode,
SingleCollectorCollectorMode
}}
Show raw api
{
    "functions": [
        {
            "name": "parse",
            "desc": "",
            "params": [
                {
                    "name": "v",
                    "desc": "",
                    "lua_type": "NumOrRangeOrWeightedArray | any"
                },
                {
                    "name": "numGen",
                    "desc": "",
                    "lua_type": "Random"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "number\n"
                }
            ],
            "function_type": "static",
            "private": true,
            "source": {
                "line": 237,
                "path": "src/dropletmanager/src/Shared/DropletUtil.lua"
            }
        },
        {
            "name": "calculateDropletValues",
            "desc": "",
            "params": [
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "any | NumOrRangeOrWeightedArray"
                },
                {
                    "name": "count",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "seed",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "lifeTime",
                    "desc": "",
                    "lua_type": "NumOrRangeOrWeightedArray"
                }
            ],
            "returns": [],
            "function_type": "static",
            "private": true,
            "source": {
                "line": 251,
                "path": "src/dropletmanager/src/Shared/DropletUtil.lua"
            }
        }
    ],
    "properties": [
        {
            "name": "Enums",
            "desc": "",
            "lua_type": "{CollectorMode: {MultiCollector: CollectorMode, SingleCollector: CollectorMode}}",
            "source": {
                "line": 187,
                "path": "src/dropletmanager/src/Shared/DropletUtil.lua"
            }
        },
        {
            "name": "DROPLET_COLLISION_GROUP",
            "desc": "The default collision group for droplets",
            "lua_type": "string",
            "private": true,
            "source": {
                "line": 215,
                "path": "src/dropletmanager/src/Shared/DropletUtil.lua"
            }
        }
    ],
    "types": [
        {
            "name": "WeightedArray<T>",
            "desc": "A table of values with weights. The weights are used to calculate the probability\nof a value being chosen. The weights do not need to add up to 1. See `ProbabilityDistributor`\nfor more information.",
            "lua_type": "{ {Weight: number, Value: T} }",
            "source": {
                "line": 32,
                "path": "src/dropletmanager/src/Shared/DropletUtil.lua"
            }
        },
        {
            "name": "NumOrRange",
            "desc": "",
            "lua_type": "number | NumberRange",
            "source": {
                "line": 38,
                "path": "src/dropletmanager/src/Shared/DropletUtil.lua"
            }
        },
        {
            "name": "NumOrRangeOrWeightedArray",
            "desc": "",
            "lua_type": "NumOrRange | WeightedArray<NumOrRange>",
            "source": {
                "line": 44,
                "path": "src/dropletmanager/src/Shared/DropletUtil.lua"
            }
        },
        {
            "name": "ResourceTypeData",
            "desc": "- `[Defaults]` is a table of default values for the droplet. This can be left empty.\nThe values in this table are used to fill in any missing values in the ResourceSpawnData\nwhen a droplet is spawned as well as overriding certain behaviors internall for things\nlike magnetization.\n\n- `[SetupDroplet]` is called when a new droplet is created. Use this to setup your visuals and\nany variables you need to keep track of. All parts within this should be\n`Anchored = false, CanCollide = false, and Massless = true`.\nThe return value of this function can be accessed via Droplet:GetSetupData()\n\n- `[OnRenderUpdate]` is called every frame that the droplet is within render range of the\nLocalPlayer's Camera. Use this to update the visuals of your droplet.\nThe return value, if one is given, must be a CFrame and is used for offsetting the droplet.\n\n- `[OnDropletTimeout]` is called when the droplet times out. Use this to perform/cleanup\nany visual effects you may have.\n\n- `[OnClientClaim]` is called when the server acknowledges that the droplet has been claimed.\n\n- `[OnClientCollect]` is called when the droplet hits the player and is considered collected.\nIt should be used for collection effects and other client side things.\n\n- `[OnServerCollect]` is called once the server is informed by a client that the droplet has\nbeen collected. This is where you should perform any server side logic like actually\ngiving things like Money or Exp.",
            "fields": [
                {
                    "name": "Defaults",
                    "lua_type": "table",
                    "desc": ""
                },
                {
                    "name": "SetupDroplet",
                    "lua_type": "(droplet: Droplet) -> any?",
                    "desc": ""
                },
                {
                    "name": "OnRenderUpdate",
                    "lua_type": "((droplet: Droplet, renderTime: number) -> (CFrame?))?",
                    "desc": ""
                },
                {
                    "name": "OnDropletTimeout",
                    "lua_type": "((droplet: Droplet) -> ())?",
                    "desc": ""
                },
                {
                    "name": "OnClientClaim",
                    "lua_type": "((playerWhoCollected: Player, droplet: Droplet) -> ())?",
                    "desc": ""
                },
                {
                    "name": "OnClientCollect",
                    "lua_type": "((playerWhoCollected: Player, droplet: Droplet) -> ())?",
                    "desc": ""
                },
                {
                    "name": "OnServerCollect",
                    "lua_type": "((playerWhoCollected: Player, value: any, metadata: any) -> ())?",
                    "desc": ""
                }
            ],
            "source": {
                "line": 83,
                "path": "src/dropletmanager/src/Shared/DropletUtil.lua"
            }
        },
        {
            "name": "ResourceSpawnData",
            "desc": ":::caution Special Behaviors\nAny index that takes a `NumOrRangeOrWeightedArray` will be parsed and calculated\nahead of time internally so that the client and server are synced. For example,\nif you pass in a `NumberRange` for `Value`, the server will calculate a random\ndecimal number between the min and max, this number would then be accessed by\n`Droplet:GetValue()` on the client.\n:::",
            "fields": [
                {
                    "name": "ResourceType",
                    "lua_type": "string",
                    "desc": "The registered name of the resource type"
                },
                {
                    "name": "Value",
                    "lua_type": "any | NumOrRangeOrWeightedArray",
                    "desc": "The value of the droplet"
                },
                {
                    "name": "Metadata",
                    "lua_type": "any?",
                    "desc": "The metadata of the droplet"
                },
                {
                    "name": "SpawnLocation",
                    "lua_type": "Vector3 | CFrame | PVInstance",
                    "desc": "The location to spawn the droplet"
                },
                {
                    "name": "CollectorMode",
                    "lua_type": "CollectorMode?",
                    "desc": "The behavior of how the droplet is claimed"
                },
                {
                    "name": "PlayerTargets",
                    "lua_type": "Player | {Player}?",
                    "desc": "The players that can collect the droplet"
                },
                {
                    "name": "LifeTime",
                    "lua_type": "NumOrRange?",
                    "desc": "The time before the droplet dissapears"
                },
                {
                    "name": "Count",
                    "lua_type": "NumOrRangeOrWeightedArray?",
                    "desc": "The number of droplets to spawn"
                },
                {
                    "name": "EjectionDuration",
                    "lua_type": "NumOrRangeOrWeightedArray?",
                    "desc": "The time it takes to spew out all the droplets"
                },
                {
                    "name": "EjectionHorizontalVelocity",
                    "lua_type": "NumOrRangeOrWeightedArray?",
                    "desc": "The horizontal velocity of the droplets when they are ejected"
                },
                {
                    "name": "EjectionVerticalVelocity",
                    "lua_type": "NumOrRangeOrWeightedArray?",
                    "desc": "The vertical velocity of the droplets when they are ejected"
                }
            ],
            "source": {
                "line": 132,
                "path": "src/dropletmanager/src/Shared/DropletUtil.lua"
            }
        },
        {
            "name": "CollectorMode",
            "desc": "The behavior of how the droplet is claimed.\n\n- `MultiCollector` - Many players can collect this droplet, each has their own individual instance\n\n- `SingleCollector` - Only one player can collect this droplet",
            "lua_type": "\"MultiCollector\" | \"SingleCollector\"",
            "source": {
                "line": 199,
                "path": "src/dropletmanager/src/Shared/DropletUtil.lua"
            }
        }
    ],
    "name": "DropletUtil",
    "desc": "Internal utility functions for droplets",
    "source": {
        "line": 8,
        "path": "src/dropletmanager/src/Shared/DropletUtil.lua"
    }
}