@turbowarp/types-tw
    Preparing search index...

    Interface Runtime

    interface Runtime {
        _blockInfo: ExtensionInfo[];
        _cloneCounter: number;
        _editingTarget: RenderedTarget | null;
        _hats: Record<string, HatInfo>;
        _lastStepTime: number;
        _primitives: Record<string, Function>;
        _steppingInterval: number | null;
        addonBlocks: Record<string, AddonBlock>;
        audioEngine: AudioEngine;
        cloudOptions: CloudOptions;
        compatibilityMode: boolean;
        compilerOptions: CompilerOptions;
        currentMSecs: number;
        currentStepTime: number | null;
        debug: boolean;
        enforcePrivacy: boolean;
        executableTargets: RenderedTarget[];
        extensionManager: ExtensionManager;
        extensionStorage: ExtensionStorage;
        externalCommunicationMethods: Record<string, boolean>;
        flyoutBlocks: Blocks;
        fontManager: FontManager;
        frameLoop: FrameLoop;
        interpolationEnabled: boolean;
        ioDevices: IODevices;
        isPackaged: boolean;
        monitorBlocks: Blocks;
        origin: string | null;
        platform: { name: string; url: string };
        profiler: Profiler | null;
        redrawRequested: boolean;
        renderer: RenderWebGL;
        runtimeOptions: RuntimeOptions;
        sequencer: Sequencer;
        stageHeight: number;
        stageWidth: number;
        storage: GUIScratchStorage;
        targets: RenderedTarget[];
        threadMap: Map<string, Thread>;
        threads: Thread[];
        turboMode: boolean;
        v2BitmapAdapter?: BitmapAdapter;
        _generateAllProjectOptions(): unknown;
        _getMonitorThreadCount(threads: Thread[]): number;
        _pushThread(
            topBlockId: string,
            target: RenderedTarget,
            options?: { stackClick?: boolean; updateMonitor?: boolean },
        ): Thread;
        _restartThread(thread: Thread): Thread;
        _step(): void;
        _stopThread(thread: Thread): void;
        addAddonBlock(addonBlock: AddonBlockOptions): void;
        addCloudVariable(): void;
        addTarget(target: RenderedTarget): void;
        allScriptsByOpcodeDo(
            opcode: string,
            callback: (script: RuntimeScriptCache, target: RenderedTarget) => void,
            target?: RenderedTarget,
        ): void;
        allScriptsDo(
            callback: (blockId: string, target: RenderedTarget) => void,
            target?: RenderedTarget,
        ): void;
        attachAudioEngine(audioEngine: AudioEngine): void;
        attachRenderer(renderer: RenderWebGL): void;
        attachStorage(storage: ScratchStorage): void;
        attachV2BitmapAdapter(bitmapAdapter: BitmapAdapter): void;
        canAddCloudVariable(): boolean;
        changeCloneCounter(changeAmount: number): void;
        clonesAvailable(): boolean;
        connectPeripheral(extensionID: string, peripheralId: number): void;
        convertToPackagedRuntime(): void;
        createNewGlobalVariable(variableName: string): ScalarVariable;
        createNewGlobalVariable(
            variableName: string,
            variableId: string,
        ): ScalarVariable;
        createNewGlobalVariable(
            variableName: string,
            variableId: string,
            type: "",
        ): ScalarVariable;
        createNewGlobalVariable(
            variableName: string,
            variableId: string,
            type: "list",
        ): ListVariable;
        createNewGlobalVariable(
            variableName: string,
            variableId: string,
            type: "broadcast_msg",
        ): BroadcastVariable;
        disableProfiling(): void;
        disconnectPeripheral(extensionID: string): void;
        dispose(): void;
        disposeTarget(target: RenderedTarget): void;
        emit<K extends keyof RuntimeEventMap>(
            event: K,
            ...args: EventEmitterArgs<RuntimeEventMap, K>,
        ): void;
        emitCompileError(target: RenderedTarget, error: unknown): void;
        emitProjectChanged(): void;
        emitProjectLoaded(): void;
        enableDebug(): void;
        enableProfiling(callback: (profilerFrame: ProfilerFrame) => void): void;
        findProjectOptionsComment(): Comment | null;
        fireTargetWasCreated(
            newTarget: RenderedTarget,
            oldTarget?: RenderedTarget,
        ): void;
        fireTargetWasRemoved(target: RenderedTarget): void;
        generateDifferingProjectOptions(): unknown;
        getAddonBlock(procedureCode: string): AddonBlock;
        getAllVarNamesOfType(variableType: VM.VariableType): string[];
        getBlocksXML(target?: RenderedTarget): { id: string; xml: string }[];
        getEditingTarget(): RenderedTarget | null;
        getIsEdgeActivatedHat(opcode: string): boolean;
        getIsHat(opcode: string): boolean;
        getLabelForOpcode(
            opcode: string,
        ): { category: "extension"; label: string } | undefined;
        getNumberOfCloudVariables(): number;
        getOpcodeFunction(opcode: string): Function;
        getPeripheralIsConnected(extensionID: string): boolean;
        getSpriteTargetByName(spriteName: string): RenderedTarget | undefined;
        getTargetByDrawableId(drawableID: number): RenderedTarget | undefined;
        getTargetById(targetId: string): RenderedTarget | undefined;
        getTargetForStage(): RenderedTarget | undefined;
        greenFlag(): void;
        hasCloudData(): boolean;
        isActiveThread(thread: Thread): boolean;
        isWaitingThread(thread: Thread): boolean;
        listeners<K extends keyof RuntimeEventMap>(
            event: K,
        ): EventEmitterCallback<RuntimeEventMap, K>[];
        moveExecutable(target: RenderedTarget, delta: number): void;
        off<K extends keyof RuntimeEventMap>(
            event: K,
            callback: EventEmitterCallback<RuntimeEventMap, K>,
        ): void;
        on<K extends keyof RuntimeEventMap>(
            event: K,
            callback: EventEmitterCallback<RuntimeEventMap, K>,
        ): void;
        once<K extends keyof RuntimeEventMap>(
            event: K,
            callback: EventEmitterCallback<RuntimeEventMap, K>,
        ): void;
        parseProjectOptions(): void;
        precompile(): void;
        quit(): void;
        removeCloudVariable(): void;
        removeExecutable(target: RenderedTarget): void;
        removeListener<K extends keyof RuntimeEventMap>(
            event: K,
            callback: EventEmitterCallback<RuntimeEventMap, K>,
        ): void;
        requestBlocksUpdate(): void;
        requestRedraw(): void;
        requestTargetsUpdate(target: RenderedTarget): void;
        requestToolboxExtensionsUpdate(): void;
        resetAllCaches(): void;
        scanForPeripheral(extensionID: string): void;
        setCompilerOptions(compilerOptions: Partial<CompilerOptions>): void;
        setEditingTarget(target: RenderedTarget): void;
        setEnforcePrivacy(enforcePrivacy: boolean): void;
        setExecutablePosition(target: RenderedTarget, newIndex: number): void;
        setExternalCommunicationMethod(method: string, enabled: boolean): void;
        setFramerate(framerate: number): void;
        setInEditor(inEditor: boolean): void;
        setInterpolation(interpolation: boolean): void;
        setRuntimeOptions(runtimeOptions: Partial<RuntimeOptions>): void;
        setStageSize(width: number, height: number): void;
        start(): void;
        startHats(
            opcode: string,
            matchFields?: Record<string, unknown>,
            target?: RenderedTarget,
        ): Thread[] | undefined;
        stopAll(): void;
        stopForTarget(target: RenderedTarget): void;
        storeProjectOptions(): void;
        toggleScript(
            topBlockId: string,
            options?: { stackClick?: boolean; target?: string },
        ): void;
        updateCurrentMSecs(): void;
        updatePrivacy(): void;
        visualReport(target: RenderedTarget, blockId: string, value: any): void;
    }

    Hierarchy (View Summary)

    Index

    Properties

    Methods

    Properties

    _blockInfo: ExtensionInfo[]
    _cloneCounter: number
    _editingTarget: RenderedTarget | null
    _hats: Record<string, HatInfo>
    _lastStepTime: number
    _primitives: Record<string, Function>
    _steppingInterval: number | null

    Interval ID returned by setInterval(). null if accessed before the project has started.

    addonBlocks: Record<string, AddonBlock>
    audioEngine: AudioEngine
    cloudOptions: CloudOptions
    compatibilityMode: boolean

    If true, the runtime is running at 60 FPS. If false, the runtime is running at 30 FPS.

    compilerOptions: CompilerOptions
    currentMSecs: number
    currentStepTime: number | null

    The time of a step, measured in milliseconds. null if accessed before the project has started.

    debug: boolean
    enforcePrivacy: boolean
    executableTargets: RenderedTarget[]
    extensionManager: ExtensionManager
    extensionStorage: ExtensionStorage
    externalCommunicationMethods: Record<string, boolean>
    flyoutBlocks: Blocks
    fontManager: FontManager
    frameLoop: FrameLoop
    interpolationEnabled: boolean
    ioDevices: IODevices
    isPackaged: boolean

    This refers to the "Remove raw asset data after loading to save RAM" option in the packager. Thus, this may be false even when the project has been packaged. To detect the packager, detect the precense of scaffolding instead.

    monitorBlocks: Blocks
    origin: string | null
    platform: { name: string; url: string }
    profiler: Profiler | null
    redrawRequested: boolean
    renderer: RenderWebGL
    runtimeOptions: RuntimeOptions
    sequencer: Sequencer
    stageHeight: number
    stageWidth: number
    targets: RenderedTarget[]
    threadMap: Map<string, Thread>
    threads: Thread[]
    turboMode: boolean
    v2BitmapAdapter?: BitmapAdapter

    Methods

    • Increment the value of the runtime's cloud variable counter. Check the value before you call this method; it will let the counter go above the limit. This method does not actually create a new cloud variable.

      Returns void

    • Returns true if the runtime's cloud variable counter is under the limit.

      Returns boolean

    • Parameters

      • extensionID: string
      • peripheralId: number

      Returns void

    • Parameters

      • opcode: string

      Returns { category: "extension"; label: string } | undefined

    • Returns the value of the runtime's cloud variable counter.

      Returns number

    • Parameters

      • extensionID: string

      Returns boolean

    • Find a sprite's original target (not a clone or stage) using the sprite's name. Returns undefined if the target doesn't exist.

      Parameters

      • spriteName: string

      Returns RenderedTarget | undefined

    • Returns true if the runtime's cloud variable counter is non-zero.

      Returns boolean

    • A thread is considered active if it is in the thread list and is not STATUS_DONE.

      Parameters

      Returns boolean

    • A thread is considered waiting if:

      • It is in STATUS_PROMISE_WAIT, or
      • It is in STATUS_YIELD_TICK, or
      • It is not considered active

      Parameters

      Returns boolean

    • Decrement the value of the runtime's cloud variable counter. Check the value before you call this method; it will let the counter go under 0. This method does not actually remove a cloud variable.

      Returns void

    • Parameters

      • enforcePrivacy: boolean

      Returns void

    • Parameters

      • method: string
      • enabled: boolean

      Returns void

    • Parameters

      • width: number
      • height: number

      Returns void

    • Parameters

      • topBlockId: string
      • Optionaloptions: { stackClick?: boolean; target?: string }

      Returns void