Skip to main content

ActionContext

This item only works when running on the client. Client

Handed to every action when its step becomes active, and to every callback that action takes.

It is how an action reaches the shared guidance tools and how it ends the step. An action never talks to the Tutorial object directly, which is what lets the same action be reused across tutorials.

FocusUI.to(shopButton, {
	Clicked = function(context)
		if playerHasEnoughCoins() then
			context:Advance()
		else
			context.Pointer:PointTo(coinChest)
		end
	end,
})

Properties

Step

This item is read only and cannot be modified. Read Only
ActionContext.Step: number

Order number of the step this action belongs to.

Janitor

This item is read only and cannot be modified. Read Only
ActionContext.Janitor: Janitor

Cleanup scope for the step, not for the action.

Everything you register here is destroyed the moment the step ends, which is why an action never has to undo its own work and why no step inherits leftovers from the one before it.

Custom.new(function(context)
	const connection = someSignal:Connect(onFired)
	context.Janitor:add(connection, "Disconnect")
end)

Spotlight

This item is read only and cannot be modified. Read Only
ActionContext.Spotlight: Spotlight

The dim overlay, shared by every step of this tutorial.

Pointer

This item is read only and cannot be modified. Read Only
ActionContext.Pointer: WorldPointer

The world guidance, shared by every step of this tutorial.

Camera

This item is read only and cannot be modified. Read Only
ActionContext.Camera: CameraTour

The cinematic camera, shared by every step of this tutorial.

Functions

Advance

ActionContext:Advance() → ()

Ends this step and opens the next one, or completes the tutorial if this was the last.

This is what Advance = true expands to. Call it directly when the decision needs a condition the kit cannot know about.

Complete

ActionContext:Complete() → ()

Ends the whole tutorial from inside a step.

GoTo

ActionContext:GoTo(
stepnumber--

Order number to jump to

) → ()

Jumps to any step, which is how you branch.

Dialog.new({
	Lines = { "Have you played before?" },
	Choices = {
		{ Text = "First time", Advance = true },
		{ Text = "Skip ahead", GoTo = 12 },
	},
})
Show raw api
{
    "functions": [
        {
            "name": "Advance",
            "desc": "Ends this step and opens the next one, or completes the tutorial if this was the last.\n\nThis is what `Advance = true` expands to. Call it directly when the decision needs a condition\nthe kit cannot know about.",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 103,
                "path": "src/Types.luau"
            }
        },
        {
            "name": "Complete",
            "desc": "Ends the whole tutorial from inside a step.",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 110,
                "path": "src/Types.luau"
            }
        },
        {
            "name": "GoTo",
            "desc": "Jumps to any step, which is how you branch.\n\n```lua\nDialog.new({\n\tLines = { \"Have you played before?\" },\n\tChoices = {\n\t\t{ Text = \"First time\", Advance = true },\n\t\t{ Text = \"Skip ahead\", GoTo = 12 },\n\t},\n})\n```",
            "params": [
                {
                    "name": "step",
                    "desc": "Order number to jump to",
                    "lua_type": "number"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 128,
                "path": "src/Types.luau"
            }
        }
    ],
    "properties": [
        {
            "name": "Step",
            "desc": "Order number of the step this action belongs to.",
            "lua_type": "number",
            "readonly": true,
            "source": {
                "line": 51,
                "path": "src/Types.luau"
            }
        },
        {
            "name": "Janitor",
            "desc": "Cleanup scope for the step, not for the action.\n\nEverything you register here is destroyed the moment the step ends, which is why an action never\nhas to undo its own work and why no step inherits leftovers from the one before it.\n\n```lua\nCustom.new(function(context)\n\tconst connection = someSignal:Connect(onFired)\n\tcontext.Janitor:add(connection, \"Disconnect\")\nend)\n```",
            "lua_type": "Janitor",
            "readonly": true,
            "source": {
                "line": 69,
                "path": "src/Types.luau"
            }
        },
        {
            "name": "Spotlight",
            "desc": "The dim overlay, shared by every step of this tutorial.",
            "lua_type": "Spotlight",
            "readonly": true,
            "source": {
                "line": 77,
                "path": "src/Types.luau"
            }
        },
        {
            "name": "Pointer",
            "desc": "The world guidance, shared by every step of this tutorial.",
            "lua_type": "WorldPointer",
            "readonly": true,
            "source": {
                "line": 85,
                "path": "src/Types.luau"
            }
        },
        {
            "name": "Camera",
            "desc": "The cinematic camera, shared by every step of this tutorial.",
            "lua_type": "CameraTour",
            "readonly": true,
            "source": {
                "line": 93,
                "path": "src/Types.luau"
            }
        }
    ],
    "types": [],
    "name": "ActionContext",
    "desc": "Handed to every action when its step becomes active, and to every callback that action takes.\n\nIt is how an action reaches the shared guidance tools and how it ends the step. An action never\ntalks to the [Tutorial] object directly, which is what lets the same action be reused across\ntutorials.\n\n```lua\nFocusUI.to(shopButton, {\n\tClicked = function(context)\n\t\tif playerHasEnoughCoins() then\n\t\t\tcontext:Advance()\n\t\telse\n\t\t\tcontext.Pointer:PointTo(coinChest)\n\t\tend\n\tend,\n})\n```",
    "realm": [
        "Client"
    ],
    "source": {
        "line": 43,
        "path": "src/Types.luau"
    }
}