Pausable Debugger
PausableDebugger
Defines an interface that represents a pausable debugger.
Members
Extra Functions
The extra functions that are available on this type.
Details
See the following functions for more information:
updateBotLinks(bot, idMap)
applyDiffToSnapshot(snapshot, diff)
applyMod(bot, ...mods)
assert(condition, message)
assertEqual(first, second)
atPosition(dimension, x, y)
byCreator(bot)
byID(id)
byMod(mod)
bySpace(space)
byTag(tag, filter)
clearAnimations(bot, tag)
clearTagMasks(bot, space)
deleteTagMaskText(bot, tag, index, count, space)
deleteTagText(bot, tag, index, count)
diffSnapshots(first, second)
either(...filters)
getBotLinks(bot)
getBotPosition(bot, dimension)
getBotRotation(bot, dimension)
getBotTagValues(tag, filter)
getFormattedJSON(data)
getID(bot)
getJSON(data)
getLink(...bots)
getMod(bot, ...tags)
getSnapshot(bots)
getTag(bot, ...tags)
inDimension(dimension)
inStack(bot, dimension)
insertTagMaskText(bot, tag, index, text, space)
insertTagText(bot, tag, index, text)
neighboring(bot, dimension, direction)
not(filter)
remote(action, selector, allowBatching)
sendRemoteData(remoteId, name, arg)
removeTags(bot, tagSection)
renameTag(bot, originalTag, newTag)
sendRemoteData(remoteId, name, arg)
setTag(bot, tag, value)
setTagMask(bot, tag, value, space)
subtractMods(bot, ...mods)
superShout(eventName, arg)
uuid()
action ActionActions
The action-related actions that are available in this debugger.
Details
See the following functions for more information:
os OSActions
The OS actions that are available in this debugger.
Details
See the following functions for more information:
os.beginAudioRecording(options)
os.endAudioRecording()
os.attachDebugger(debug, options)
os.createDebugger(options)
os.createDebugger(options)
os.focusOn(bot, options)
os.focusOn(position, options)
os.getExecutingDebugger()
os.showInput(currentValue, options)
os.addBotDropGrid(bot, ...targets)
os.addBotDropSnap(bot, ...targets)
os.addDropGrid(...targets)
os.addDropSnap(...targets)
os.applyUpdatesToInst(updates)
os.arSupported()
os.beginAudioRecording(options)
os.bufferFormAddressGLTF(address)
os.bufferSound(url)
os.calculateRayFromCamera(portal, viewportCoordinates)
os.calculateScreenCoordinatesFromViewportCoordinates(portal, coordinates)
os.calculateViewportCoordinatesFromPosition(portal, position)
os.calculateViewportCoordinatesFromScreenCoordinates(portal, coordinates)
os.cancelSound(soundId)
os.capturePhoto(options)
os.capturePortalScreenshot()
os.classifyImages(options)
os.closeBarcodeScanner()
os.closeCircleWipe(options)
os.closeImageClassifier()
os.closePhotoCamera()
os.closeQRCodeScanner()
os.compileApp(appId, content)
os.convertGeolocationToWhat3Words(location)
os.countEvents(recordNameOrKey, eventName, endpoint)
os.createInitializationUpdate(bots)
os.device()
os.disableAR()
os.disablePointOfView()
os.disableVR()
os.disableWakeLock()
os.download(data, filename, mimeType)
os.downloadBots(bots, filename)
os.downloadBotsAsInitialzationUpdate(bots, filename)
os.downloadInst()
os.downloadInst()
os.enableAR(options)
os.enableCollaboration()
os.enableCustomDragging()
os.enablePointOfView(center, imu)
os.enableVR(options)
os.endAudioRecording()
os.eraseData(recordKeyOrName, address, endpoint)
os.eraseFile(recordKeyOrName, result, endpoint)
os.eraseFile(recordKeyOrName, url, endpoint)
os.eraseManualApprovalData(recordKeyOrName, address, endpoint)
os.eraseNotification(recordName, address, options)
os.eraseWebhook(recordName, address, options)
os.exitFullscreenMode()
os.getAverageFrameRate()
os.getCameraPosition(portal)
os.getCameraRotation(portal)
os.getCurrentDimension()
os.getCurrentInst()
os.getCurrentInstRecord()
os.getCurrentInstUpdate()
os.getCurrentInst()
os.getData(recordKeyOrName, address, endpoint)
os.getDimensionalDepth(dimension)
os.getFile(result, endpoint)
os.getFile(url, endpoint)
os.getFocusPoint(portal)
os.getGeolocation()
os.getInputList()
os.getInputState(controller, button)
os.getInstStateFromUpdates(updates)
os.getManualApprovalData(recordKeyOrName, address, endpoint)
os.getMediaPermission(options)
os.getMenuDimension()
os.getMiniPortalDimension()
os.getWebhook(recordName, address, options)
os.getPointerDirection(pointer)
os.getPointerPosition(pointer)
os.getPointerRotation(pointer)
os.getPortalDimension(portal)
os.getPrivateFile(result, endpoint)
os.getPrivateFile(url, endpoint)
os.getPublicFile(result)
os.getPublicFile(url)
os.getPublicRecordKey(name)
os.getRecordsEndpoint()
os.getRoomOptions(roomName)
os.getRoomRemoteOptions(roomName, remoteId)
os.getRoomTrackOptions(roomName, address)
os.getSubjectlessPublicRecordKey(name)
os.getWakeLockConfiguration()
os.getWebhook(recordName, address, options)
os.goToDimension(dimension)
os.goToURL(url)
os.grantInstAdminPermission(recordName, options)
os.grantInstRole(recordName, role, inst, expireTimeMs, options)
os.grantPermission(recordName, permission, options)
os.grantUserRole(recordName, role, userId, expireTimeMs, options)
os.hasBotInMiniPortal(bots)
os.hideBarcode()
os.hideChat()
os.hideHtml()
os.hideQRCode()
os.hideTips(tipIds)
os.importAUX(urlOrJSON)
os.inSheet()
os.isCollaborative()
os.isInDimension(dimension)
os.isRecordKey(key)
os.joinRoom(roomName, options)
os.ldrawCountTextBuildSteps(address)
os.ldrawCountTextBuildSteps(text)
os.leaveRoom(roomName, options)
os.listBuiltinTags()
os.listData(recordKeyOrName, startingAddress, endpoint)
os.listDataByMarker(recordKeyOrName, marker, startingAddress, options)
os.listFormAnimations(botOrAddress)
os.listInstUpdates()
os.listNotificationSubscriptions(recordName, address, options)
os.listNotifications(recordName, startingAddress, options)
os.listNotificationsByMarker(recordName, marker, startingAddress, options)
os.listUserNotificationSubscriptions(options)
os.listUserStudios(endpoint)
os.listWebhooks(recordName, startingAddress, options)
os.listWebhooksByMarker(recordName, marker, startingAddress, options)
os.loadInst(id)
os.loadInst(id)
os.log(...args)
os.meetCommand(command, ...args)
os.meetFunction(functionName, ...args)
os.mergeInstUpdates(updates)
os.openBarcodeScanner(camera)
os.openCircleWipe(options)
os.openDevConsole()
os.openImageClassifier(options)
os.openPhotoCamera(options)
os.openQRCodeScanner(camera)
os.openURL(url)
os.parseBotsFromData(jsonOrPdf)
os.playSound(url)
os.raycast(portal, origin, direction)
os.raycastFromCamera(portal, viewportCoordinates)
os.recordData(recordKeyOrRecordName, address, data, endpointOrOptions)
os.recordEvent(recordKeyOrName, eventName, endpoint)
os.recordFile(recordKeyOrName, data, options, endpoint)
os.recordManualApprovalData(recordKeyOrRecordName, address, data, endpointOrOptions)
os.recordNotification(recordName, notification, options)
os.recordWebhook(recordName, webhook, options)
os.registerApp(portalId, bot)
os.registerTagPrefix(prefix, options)
os.remoteCount(inst)
os.remotes()
os.replaceDragBot(bot)
os.reportInst()
os.requestAuthBot()
os.requestAuthBotInBackground()
os.requestFullscreenMode()
os.requestWakeLock()
os.revokeInstRole(recordName, role, inst, options)
os.revokePermission(recordName, permissionId, options)
os.revokeUserRole(recordName, role, userId, options)
os.run(script)
os.runWebhook(recordName, address, input, options)
os.sendNotification(recordName, address, payload, options)
os.setClipboard(text)
os.setRoomOptions(roomName, options)
os.setRoomTrackOptions(roomName, address, options)
os.share(options)
os.showAccountInfo()
os.showBarcode(code, format)
os.showConfirm(options)
os.showHtml(html)
os.showInputForTag(bot, tag, options)
os.showJoinCode(inst, dimension)
os.showQRCode(code)
os.showUploadAuxFile()
os.showUploadFiles()
os.sleep(time)
os.startFormAnimation(botOrBots, nameOrIndex, options)
os.stopFormAnimation(botOrBots, options)
os.subscribeToNotification(recordName, address, options)
os.tip(message, pixelX, pixelY, duration)
os.toast(message, duration)
os.totalRemoteCount()
os.unloadInst(id)
os.unloadInst(id)
os.unregisterApp(appId)
os.unsubscribeFromNotification(subscriptionId, options)
os.version()
os.vrSupported()
os.agreedUponTime
os.deadReckoningTime
os.instLatency
os.instTimeOffset
os.instTimeOffsetSpread
os.localTime
os.registerTagPrefix(prefix, options)
os.remotes()
os.remotes()
os.remoteCount(inst)
os.remoteCount(inst)
os.totalRemoteCount()
os.totalRemoteCount()
os.sleep(time)
web WebActions
The web actions that are available in this debugger.
Details
See the following functions for more information:
setPauseTrigger(botOrIdOrTrigger: (string | Bot), tag?: string, options?: PauseTriggerOptions): PauseTrigger
Registers or updates a pause trigger with this debugger. Pause triggers can be used to tell the debugger when you want it to stop execution. You specify the bot, tag, line and column numbers and the debugger will stop before/after it executes the code at that location.
The first parameter is a (string | Bot) and is the bot, or bot ID that should be registered.
The second parameter is optional and is a string and is the name of the tag that the trigger should be set on.
The third parameter is optional and is a PauseTriggerOptions and is the options that go with this pause trigger.
Examples
Set a pause trigger on a scriptconst debug = await os.createDebugger({
pausable: true
});
const b = await debug.create({
test: '@os.toast("Hello, World!")'
});
const trigger = debug.setPauseTrigger(b, 'test', {
lineNumber: 1,
columnNumber: 1
});Update a pause trigger on a scriptconst debug = await os.createDebugger({
pausable: true
});
const b = await debug.create({
test: '@os.toast("Hello, World!")'
});
let trigger = debug.setPauseTrigger(b, 'test', {
lineNumber: 1,
columnNumber: 1
});
trigger = debug.setPauseTrigger({
...trigger,
states: ['before', 'after']
});setPauseTrigger(trigger: PauseTrigger): PauseTrigger
Registers or updates a pause trigger with a debugger. Returns the newly created trigger.
Pause triggers can be used to tell the debugger where you want it to temporarily stop execution. You specify the bot, tag, line and column numbers, and the debugger will stop before it executes the code at that location. Additionally, the debugger will call all handlers that have been registered with debug.onPause.
The first parameter is a PauseTrigger and is the trigger that should be registered or updated.
changeState(bot: Bot, stateName: string, groupName?: string): Promise<void>
Changes the state that the given bot is in.
The first parameter is a Bot and is the bot to change.
The second parameter is a string and is the state that the bot should move to.
The third parameter is optional and is a string and is the group of states that the bot's state should change in. (Defaults to "state")
create(...mods: Mod[]): Promise<(Bot | Bot[])>
Creates a new bot and returns it.
Each parameter is a Mod and are the mods which specify the new bot's tag values. If given a mod with no tags, then an error will be thrown.
Examples
Create a red bot without a parent.let debugger = await os.createDebugger({
pausable: true
});
let redBot = await debugger.create(null, { "color": "red" });Create a red bot and a blue bot with `this` as the parent.let debugger = await os.createDebugger({
pausable: true
});
let [redBot, blueBot] = await debugger.create(this, [
{ "color": "red" },
{ "color": "blue" }
]);disablePauseTrigger(triggerOrId: (string | PauseTrigger)): void
Disables the given pause trigger. Disabled pause triggers will continue to be listed with debug.listPauseTriggers, but will not cause a pause to happen while they are disabled.
The first parameter is a (string | PauseTrigger) and is the trigger or trigger ID that should be disabled.
Examples
Disable a pause triggerconst debug = await os.createDebugger({
pausable: true
});
const b = await debug.create({
test: '@os.toast("Hello, World!")'
});
const trigger = debug.setPauseTrigger(b, 'test', {
lineNumber: 1,
columnNumber: 1
});
debug.disablePauseTrigger(trigger);enablePauseTrigger(triggerOrId: (string | PauseTrigger)): void
Enables the given pause trigger
The first parameter is a (string | PauseTrigger) and is the trigger or trigger ID that should be enabled.
Examples
Enable a pause triggerconst debug = await os.createDebugger({
pausable: true
});
const b = await debug.create({
test: '@os.toast("Hello, World!")'
});
const trigger = debug.setPauseTrigger(b, 'test', {
lineNumber: 1,
columnNumber: 1,
enabled: false
});
debug.enablePauseTrigger(trigger);getAllActions(): BotAction[]
Gets the list of action objects that have been performed by bots in the current debugger. Action objects are used by CasualOS to represent changes to bots or external effects that should be performed. Examples of this are
create(...mods)
,os.toast(message, duration)
andos.enableVR(options)
.Examples
Get the list of bot changes and actions that have been performed in a debuggerconst debug = await os.createDebugger();
debug.create({
test: '@os.toast("Hello")'
});
debug.shout("test");
const actions = debug.getAllActions();
assertEqual(actions, [
{
type: 'add_bot',
id: 'uuid-1',
bot: {
id: 'uuid-1',
tags: {
test: '@os.toast("Hello")'
}
}
},
{
type: 'show_toast',
message: 'Hello',
duration: 2000
}
]);getBotActions(): BotAction[]
Gets the list of bot actions that have been performed by bots in the current debugger. Action objects are used by CasualOS to represent changes to bots or external effects that should be performed. Bot actions are actions that immediately change bots or bot tags or masks.
Examples of bot actions are
create(...mods)
,destroy(bot)
orsetTagMask(bot, tag, value, space)
.Examples
Get the list of bot changes that have been performed in a debuggerconst debug = await os.createDebugger();
debug.create({
test: '@os.toast("Hello")'
});
debug.shout("test");
const actions = debug.getBotActions();
assertEqual(actions, [
{
type: 'add_bot',
id: 'uuid-1',
bot: {
id: 'uuid-1',
tags: {
test: '@os.toast("Hello")'
}
}
},
]);getCallStack(): DebuggerCallFrame[]
Gets the current call stack for the debugger. Call stacks are useful for determining program flow and how scripts interact with each other.
Examples
Get the call stack from a debuggerconst debug = os.createDebugger({
pausable: true
});
const callStack = debug.getCallStack();getCommonActions(): BotAction[]
Gets the list of common action objects that have been performed by bots in the current debugger. Action objects are used by CasualOS to represent changes to bots or external effects that should be performed. Common actions are actions that do not immediately change bots or bot tags or masks.
Examples of common actions are
os.toast(message, duration)
andos.enableVR(options)
.Examples
Get the list of actions that have been performed in a debuggerconst debug = await os.createDebugger();
debug.create({
test: '@os.toast("Hello")'
});
debug.shout("test");
const actions = debug.getCommonActions();
assertEqual(actions, [
{
type: 'show_toast',
message: 'Hello',
duration: 2000
}
]);getErrors(): any[]
Gets the list of errors that have occurred in the current debugger. Errors occur when an exceptional event happens in a script and prevents the rest of the script from executing.
Debuggers capture these errors and let you inspect them afterwards.
Examples
Get the list of errors that have happened in a debuggerconst debug = await os.createDebugger();
debug.create({
test: '@throw new Error("My Error")'
});
debug.shout("test");
const errors = debug.getErrors();
assertEqual(errors.length, 1);
assertEqual(errors[0].error, new Error("My Error"));
assertEqual(errors[0].tag, "test");listCommonPauseTriggers(botOrId: (string | Bot), tag: string): PossiblePauseTriggerLocation[]
Gets a list of common trigger locations for the specified tag on the specified bot. Returns an array containing the list of possible pause trigger locations.
The first parameter is a (string | Bot) and is the bot or bot ID that the locations should be listed for.
The second parameter is a string and is the name of the tag that the locations should be listed for.
Examples
List common trigger locations for a scriptconst debug = await os.createDebugger({
pausable: true
});
const b = await debug.create({
test: '@os.toast("Hello, World!")'
});
const triggerLocations = debug.listCommonPauseTriggers(b, 'test');Register a trigger from a common locationconst debug = await os.createDebugger({
pausable: true
});
const b = await debug.create({
test: '@os.toast("Hello, World!")'
});
const triggerLocations = debug.listCommonPauseTriggers(b, 'test');
const trigger = debug.setPauseTrigger(b, 'test', {
lineNumber: triggerLocations[0].lineNumber,
columnNumber: triggerLocations[0].columnNumber,
states: triggerLocations[0].possibleStates
});listPauseTriggers(): PauseTrigger[]
Gets the list of pause triggers that have been registered with this debugger.
Examples
List the triggers that are set on this debuggerconst debug = await os.createDebugger({
pausable: true
});
const b = await debug.create({
test: '@os.toast("Hello, World!")'
});
const trigger = debug.setPauseTrigger(b, 'test', {
lineNumber: 1,
columnNumber: 1,
enabled: false
});
const triggers = debug.listPauseTriggers();onAfterScriptUpdatedTag(listener: (update: DebuggerTagUpdate) => void): void
Registers the given handler function to be called after any tag is updated in the debugger.
The first parameter is a (update: DebuggerTagUpdate) => void and is the function that should be called when a tag is updated.
Examples
Listen for tag updates in a debuggerconst debug = await os.createDebugger({
pausable: true
});
// Register a listener that gets called whenever a tag is updated.
debug.onAfterScriptUpdatedTag(update => {
console.log('tag updated', update);
});
// Because the debugger is pausable, the create() function returns a promise
// because it callsonAfterScriptUpdatedTagMask(listener: (update: DebuggerTagMaskUpdate) => void): void
Registers the given handler function to be called after any tag mask is updated in the debugger.
The first parameter is a (update: DebuggerTagMaskUpdate) => void and is the function that should be called when a tag mask is updated.
Examples
Listen for tag mask updates in a debuggerconst debug = await os.createDebugger({
pausable: true
});
// Register a listener that gets called whenever a tag mask is updated.
debug.onAfterScriptUpdatedTagMask(update => {
console.log('tag mask updated', update);
});
// Because the debugger is pausable, the create() function returns a promise
// because it callsonBeforeUserAction(listener: (action: BotAction) => void): void
Registers the given handler function to be called before a user action is performed in the debugger.
User actions are like normal actions, except they are generated by the CasualOS frontend. Generally, this only happens for built-in shouts and whispers. Additionally, these actions can only be automatically created for debuggers that are attached using
os.attachDebugger(debug, options)
.The first parameter is a (action: BotAction) => void and is the function that should be called before a user action is performed.
Examples
Listen for tag updates in a debuggerconst debug = await os.createDebugger({
pausable: true
});
// Register a listener that gets called whenever a user action is about to be performed.
debug.onBeforeUserAction(update => {
console.log('user action', update);
});
// Because the debugger is pausable, the create() function returns a promise
// because it callsonPause(handler: (pause: DebuggerPause) => void): void
Registers the given function to be called whenever the debugger is paused by hitting a pause trigger.
The first parameter is a (pause: DebuggerPause) => void and is the function that should be called when the debugger is paused.
Examples
Listen for pauses on a debuggerconst debug = await os.createDebugger({
pausable: true
});
debug.onPause(pause => {
console.log('pause happened!', pause);
});onScriptActionEnqueued(listener: (action: BotAction) => void): void
Registers the given handler function to be called by the debugger whenever a script enqueues an action. This occurrs for common actions like
os.toast(message, duration)
andos.showInput(currentValue, options)
.Every action that is enqueued ends up being performed.
The first parameter is a (action: BotAction) => void and is the function that should be called whenever an action is scheduled to be performed.
Examples
Listen for actions to be enqueued in a debuggerconst debug = await os.createDebugger({
pausable: true
});
// Register a listener that gets called whenever an action is scheduled to be performed.
debug.onScriptActionEnqueued(action => {
console.log('action enqueued', action);
});
// Because the debugger is pausable, the create() function returns a promise
// because it callsperformUserAction(...actions: BotAction[]): Promise<any[][]>
Performs the given actions in order as if they were user actions.
This function works similarly to
action.perform(action)
except that actions performed with it will also call handlers registered with debug.onBeforeUserAction.Each parameter is a BotAction and are the actions that should be performed.
priorityShout(eventNames: string[], arg?: any): Promise<any>
Shouts the given events in order until a bot returns a result. Returns the result that was produced or undefined if no result was produced.
The first parameter is a string[] and is the names of the events to shout.
The second parameter is optional and is a any and is the argument to shout.
removePauseTrigger(triggerOrId: (string | PauseTrigger)): void
Removes the given pause trigger from the debugger.
The first parameter is a (string | PauseTrigger) and is the trigger or trigger ID that should be removed from the debugger.
Examples
Remove a pause triggerconst debug = await os.createDebugger({
pausable: true
});
const b = await debug.create({
test: '@os.toast("Hello, World!")'
});
const trigger = debug.setPauseTrigger(b, 'test', {
lineNumber: 1,
columnNumber: 1
});
debug.removePauseTrigger(trigger);resume(pause: DebuggerPause): void
Resumes the debugger execution from the given pause.
The first parameter is a DebuggerPause and is the debugger pause that was passed to the handler of debug.onPause.
Examples
Resume execution on a debuggerconst debug = await os.createDebugger({
pausable: true
});
// Register a listener that gets called whenever a pause happens in this debugger.
debug.onPause(pause => {
// Get the current stack frame from the pause
const currentFrame = pause.callStack[pause.callStack.length - 1];
// Set the abc variable to 999
currentFrame.setVariableValue('abc', 999);
// Resume execution after the pause.
debug.resume(pause);
});
// Because the debugger is pausable, the create() function returns a promise
// because it callsshout(name: string, arg?: any): Promise<any[]>
Asks every bot in the inst to run the given action. In effect, this is like shouting to a bunch of people in a room.
The first parameter is a string and is the event name.
The second parameter is optional and is a any and is the optional argument to include in the shout.
Examples
Tell every bot to reset themselves.let debugger = await os.createDebugger({
pausable: true
});
await debugger.shout("reset()");Ask every bot for its name.let debugger = await os.createDebugger({
pausable: true
});
const names = await debugger.shout("getName()");Tell every bot say "Hi" to you.let debugger = await os.createDebugger({
pausable: true
});
await debugger.shout("sayHi()", "My Name");