@turbowarp/types
    Preparing search index...

    Interface BaseTarget

    interface BaseTarget {
        _customState: Partial<CustomState>;
        blocks: VM.Blocks;
        comments: Record<string, Comment>;
        id: string;
        runtime: Runtime;
        soundEffects?: { pan: number; pitch: number };
        variables: Record<string, Variable>;
        addListener<K extends keyof RenderedTargetEventMap>(
            event: K,
            callback: EventEmitterCallback<RenderedTargetEventMap, K>,
        ): void;
        clearEdgeActivatedValues(): void;
        createComment(
            id: string,
            blockId: string,
            text: string,
            x: number,
            y: number,
            width: number,
            height: number,
            minimized?: boolean,
        ): void;
        createVariable(
            id: string,
            name: string,
            type: VM.VariableType,
            isCloud?: boolean,
        ): void;
        deleteMonitors(): void;
        deleteVariable(id: string): void;
        dispose(): void;
        duplicateVariable(id: string, optKeepOriginalId?: boolean): Variable | null;
        duplicateVariables(optBlocks?: VM.Blocks): Record<string, Variable>;
        emit<K extends keyof RenderedTargetEventMap>(
            event: K,
            ...args: EventEmitterArgs<RenderedTargetEventMap, K>,
        ): void;
        fixUpVariableReferences(): void;
        getAllVariableNamesInScopeByType(
            type?: VM.VariableType,
            skipStage?: boolean,
        ): string[];
        getCustomState<T extends keyof CustomState>(
            name: T,
        ): CustomState[T] | undefined;
        getName(): string;
        hasEdgeActivatedValue(blockId: string): boolean;
        listeners<K extends keyof RenderedTargetEventMap>(
            event: K,
        ): EventEmitterCallback<RenderedTargetEventMap, K>[];
        lookupBroadcastByInputValue(name: string): BroadcastVariable | undefined;
        lookupBroadcastMsg(id: string, name: string): BroadcastVariable | undefined;
        lookupOrCreateList(id: string, name: string): ListVariable;
        lookupOrCreateVariable(id: string, name: string): ScalarVariable;
        lookupVariableById(id: string): Variable | undefined;
        lookupVariableByNameAndType(name: string): ScalarVariable | undefined;
        lookupVariableByNameAndType(
            name: string,
            type: "",
            skipStage?: boolean,
        ): ScalarVariable | undefined;
        lookupVariableByNameAndType(
            name: string,
            type: "list",
            skipStage?: boolean,
        ): ListVariable | undefined;
        lookupVariableByNameAndType(
            name: string,
            type: "broadcast_msg",
            skipStage?: boolean,
        ): BroadcastVariable | undefined;
        mergeVariables(
            idToBeMerged: string,
            idToMergeWith: string,
            optReferencesToUpdate?: object[],
            optNewName?: string,
        ): void;
        off<K extends keyof RenderedTargetEventMap>(
            event: K,
            callback: EventEmitterCallback<RenderedTargetEventMap, K>,
        ): void;
        on<K extends keyof RenderedTargetEventMap>(
            event: K,
            callback: EventEmitterCallback<RenderedTargetEventMap, K>,
        ): void;
        once<K extends keyof RenderedTargetEventMap>(
            event: K,
            callback: EventEmitterCallback<RenderedTargetEventMap, K>,
        ): void;
        onGreenFlag(): void;
        postSpriteInfo(spriteInfo: PostedSpriteInfo): void;
        removeListener<K extends keyof RenderedTargetEventMap>(
            event: K,
            callback: EventEmitterCallback<RenderedTargetEventMap, K>,
        ): void;
        renameVariable(id: string, newName: string): void;
        resolveVariableSharingConflictsWithTarget(
            blocks: VM.Block[],
            receivingTarget: RenderedTarget,
        ): void;
        setCustomState<T extends keyof CustomState>(
            name: T,
            value: CustomState[T],
        ): void;
        shareLocalVariableToSprite(
            varId: string,
            sprite: RenderedTarget,
            varRefs: object[],
        ): void;
        shareLocalVariableToStage(varId: string, varRefs: object[]): void;
        updateEdgeActivatedValue(blockId: string, newValue: unknown): unknown;
    }

    Hierarchy (View Summary)

    Index

    Properties

    _customState: Partial<CustomState>
    blocks: VM.Blocks
    comments: Record<string, Comment>
    id: string
    runtime: Runtime
    soundEffects?: { pan: number; pitch: number }

    Mirrors custom state.

    variables: Record<string, Variable>

    Methods

    • Parameters

      • id: string
      • blockId: string
      • text: string
      • x: number
      • y: number
      • width: number
      • height: number
      • Optionalminimized: boolean

      Returns void

    • Create a new variable. If the ID is already used, silently does nothing. isCloud is ignored if the sprite is not the stage or if the cloud variable limit has been reached.

      Parameters

      Returns void

    • Remove this target's monitors from the runtime state and remove the target-specific monitored blocks (e.g. local variables, x-position). Does not delete stage monitors like backdrop name.

      Returns void

    • Removes the variable with the given id from the dictionary of variables.

      Parameters

      • id: string

      Returns void

    • Create a clone of the variable with the given id. Returns null if the original variable was not found.

      Parameters

      • id: string
      • OptionaloptKeepOriginalId: boolean

      Returns Variable | null

    • Duplicate the dictionary of this target's variables as part of duplicating this target or making a clone.

      Parameters

      Returns Record<string, Variable>

    • Fixes up variable references in this target avoiding conflicts with pre-existing variables in the same scope. Used when uploading a target as a new sprite.

      Returns void

    • Get the names of all the variables of the given type that are in scope for this target.

      Parameters

      • Optionaltype: VM.VariableType

        Defaults to the scalar type.

      • OptionalskipStage: boolean

        Optional flag to skip the stage.

      Returns string[]

    • Parameters

      • blockId: string

      Returns boolean

    • Look for a variable by its ID in this target. If it doesn't exist in this target, will check if it exists in the stage target. If it still doesn't exist, returns undefined.

      Parameters

      • id: string

      Returns Variable | undefined

    • Merge variable references with another variable.

      Parameters

      • idToBeMerged: string
      • idToMergeWith: string
      • OptionaloptReferencesToUpdate: object[]
      • OptionaloptNewName: string

      Returns void

    • Called by runtime when the green flag is pressed.

      Returns void

    • Renames the variable with the given id to newName.

      Parameters

      • id: string
      • newName: string

      Returns void

    • Share the given variable-referencing fields with the target of the given id, resolving conflicts.

      Parameters

      Returns void

    • Share a local variable with a sprite, merging with one of the same name and type if it exists.

      Parameters

      Returns void

    • Share a local variable (and given references for that variable) to the stage.

      Parameters

      • varId: string
      • varRefs: object[]

      Returns void

    • Update an edge-activated hat block value.

      Parameters

      • blockId: string
      • newValue: unknown

      Returns unknown

      The old value for the edge-activated hat.