Skip to main content

StepUtils

Utility functions primarily used to bind animations into update loops of the Roblox engine.

Functions

bindToRenderStep

StepUtils.bindToRenderStep(
update() → boolean--

should return true while it needs to update

) → (
(...) → (),--

Connect function

() → ()--

Disconnect function

)

Binds the given update function to RunService.RenderStepped.

local spring = Spring.new(0)
local maid = Maid.new()

local startAnimation, maid._stopAnimation = StepUtils.bindToRenderStep(function()
	local animating, position = SpringUtils.animating(spring)

	print(position)

	return animating
end)

spring.t = 1
startAnimation()
tip

Be sure to call the disconnect function when cleaning up, otherwise you may memory leak.

deferWait

StepUtils.deferWait() → ()

Yields until the frame deferral is done

bindToStepped

StepUtils.bindToStepped(
update() → boolean--

should return true while it needs to update

) → (
(...) → (),--

Connect function

() → ()--

Disconnect function

)

Binds the given update function to RunService.Stepped. See StepUtils.bindToRenderStep for details.

tip

Be sure to call the disconnect function when cleaning up, otherwise you may memory leak.

bindToSignal

StepUtils.bindToSignal(
signalSignal | RBXScriptSignal,
update() → boolean--

should return true while it needs to update

) → (
(...) → (),--

Connect function

() → ()--

Disconnect function

)

Binds an update event to a signal until the update function stops returning a truthy value.

onceAtRenderPriority

StepUtils.onceAtRenderPriority(
prioritynumber,
funcfunction--

Function to call

) → function--

Call this function to cancel call

Calls the function once at the given priority level, unless the cancel callback is invoked.

onceAtStepped

StepUtils.onceAtStepped(
funcfunction--

Function to call

) → function--

Call this function to cancel call

Invokes the function once at stepped, unless the cancel callback is called.

-- Sometimes you need to defer the execution of code to make physics happy
maid:GiveTask(StepUtils.onceAtStepped(function()
	part.CFrame = CFrame.new(0, 0, )
end))

onceAtRenderStepped

StepUtils.onceAtRenderStepped(
funcfunction--

Function to call

) → function--

Call this function to cancel call

Invokes the function once at renderstepped, unless the cancel callback is called.

onceAtEvent

StepUtils.onceAtEvent(
funcfunction--

Function to call

) → function--

Call this function to cancel call

Invokes the function once at the given event, unless the cancel callback is called.

Show raw api
{
    "functions": [
        {
            "name": "bindToRenderStep",
            "desc": "Binds the given update function to [RunService.RenderStepped].\n\n```lua\nlocal spring = Spring.new(0)\nlocal maid = Maid.new()\n\nlocal startAnimation, maid._stopAnimation = StepUtils.bindToRenderStep(function()\n\tlocal animating, position = SpringUtils.animating(spring)\n\n\tprint(position)\n\n\treturn animating\nend)\n\nspring.t = 1\nstartAnimation()\n```\n\n:::tip\nBe sure to call the disconnect function when cleaning up, otherwise you may memory leak.\n:::",
            "params": [
                {
                    "name": "update",
                    "desc": "should return true while it needs to update",
                    "lua_type": "() -> boolean"
                }
            ],
            "returns": [
                {
                    "desc": "Connect function",
                    "lua_type": "(...) -> ()"
                },
                {
                    "desc": "Disconnect function",
                    "lua_type": "() -> ()"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 38,
                "path": "src/steputils/src/Shared/StepUtils.lua"
            }
        },
        {
            "name": "deferWait",
            "desc": "Yields until the frame deferral is done",
            "params": [],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 45,
                "path": "src/steputils/src/Shared/StepUtils.lua"
            }
        },
        {
            "name": "bindToStepped",
            "desc": "Binds the given update function to [RunService.Stepped]. See [StepUtils.bindToRenderStep] for details.\n\n\n:::tip\nBe sure to call the disconnect function when cleaning up, otherwise you may memory leak.\n:::",
            "params": [
                {
                    "name": "update",
                    "desc": "should return true while it needs to update",
                    "lua_type": "() -> boolean"
                }
            ],
            "returns": [
                {
                    "desc": "Connect function",
                    "lua_type": "(...) -> ()"
                },
                {
                    "desc": "Disconnect function",
                    "lua_type": "() -> ()"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 67,
                "path": "src/steputils/src/Shared/StepUtils.lua"
            }
        },
        {
            "name": "bindToSignal",
            "desc": "Binds an update event to a signal until the update function stops returning a truthy\nvalue.",
            "params": [
                {
                    "name": "signal",
                    "desc": "",
                    "lua_type": "Signal | RBXScriptSignal"
                },
                {
                    "name": "update",
                    "desc": "should return true while it needs to update",
                    "lua_type": "() -> boolean"
                }
            ],
            "returns": [
                {
                    "desc": "Connect function",
                    "lua_type": "(...) -> ()"
                },
                {
                    "desc": "Disconnect function",
                    "lua_type": "() -> ()"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 80,
                "path": "src/steputils/src/Shared/StepUtils.lua"
            }
        },
        {
            "name": "onceAtRenderPriority",
            "desc": "Calls the function once at the given priority level, unless the cancel callback is\ninvoked.",
            "params": [
                {
                    "name": "priority",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "func",
                    "desc": "Function to call",
                    "lua_type": "function"
                }
            ],
            "returns": [
                {
                    "desc": "Call this function to cancel call",
                    "lua_type": "function"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 134,
                "path": "src/steputils/src/Shared/StepUtils.lua"
            }
        },
        {
            "name": "onceAtStepped",
            "desc": "Invokes the function once at stepped, unless the cancel callback is called.\n\n```lua\n-- Sometimes you need to defer the execution of code to make physics happy\nmaid:GiveTask(StepUtils.onceAtStepped(function()\n\tpart.CFrame = CFrame.new(0, 0, )\nend))\n```",
            "params": [
                {
                    "name": "func",
                    "desc": "Function to call",
                    "lua_type": "function"
                }
            ],
            "returns": [
                {
                    "desc": "Call this function to cancel call",
                    "lua_type": "function"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 164,
                "path": "src/steputils/src/Shared/StepUtils.lua"
            }
        },
        {
            "name": "onceAtRenderStepped",
            "desc": "Invokes the function once at renderstepped, unless the cancel callback is called.",
            "params": [
                {
                    "name": "func",
                    "desc": "Function to call",
                    "lua_type": "function"
                }
            ],
            "returns": [
                {
                    "desc": "Call this function to cancel call",
                    "lua_type": "function"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 174,
                "path": "src/steputils/src/Shared/StepUtils.lua"
            }
        },
        {
            "name": "onceAtEvent",
            "desc": "Invokes the function once at the given event, unless the cancel callback is called.",
            "params": [
                {
                    "name": "event",
                    "desc": "",
                    "lua_type": "Signal | RBXScriptSignal"
                },
                {
                    "name": "func",
                    "desc": "Function to call",
                    "lua_type": "function"
                }
            ],
            "returns": [
                {
                    "desc": "Call this function to cancel call",
                    "lua_type": "function"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 185,
                "path": "src/steputils/src/Shared/StepUtils.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "StepUtils",
    "desc": "Utility functions primarily used to bind animations into update loops of the Roblox engine.",
    "source": {
        "line": 5,
        "path": "src/steputils/src/Shared/StepUtils.lua"
    }
}