Julien Savard edited this page Nov 14, 2017 · 12 revisions

These are the built-in objects, methods and properties Tiewrap adds in the global object. Modules and properties in italics are planned, but not implemented yet. The version numbers in parentheses indicates the version in which the method first appeared in, or the requirements needed so this function would be defined.

alert(message, title)

Alias to window.alert.

canvas

Holds drawing-related properties, aims to be more or less compatible with its HTML5 equivalent.

console

Standard console object for writing to stdout.

console.log('Hello World!');

Methods

assert

debug

Alias to console.log.

dir

error

exception

Alias to console.error.

format

info

log

trace

warn

process

Holds some process-related methods and properties, akin to its Node.js equivalent.

Methods

exit(code)

Immediately quits the program with exit code given in process.exitCode. Can take an optional exit code as its argument that overrides process.exitCode.

process.exit();

sleep(ms)

Delays the script for a number of milliseconds.

Properties

argv

Array holding command-line arguments.

exitCode

Sets the exit code value for when the program terminates.

platform

The operating system Tiewrap is running on.

version

String holding the Tiewrap version, usually taken from git describe.

versions

Array with the version numbers of each of the components Tiewrap has been compiled with, currently duktape, sdl and tiewrap.

require(path)

Used to call another script as a module, Node.js-style.

window

Holds methods and properties related to the SDL window.

Methods

addEventListener(event, callback)

Alias to window.on.

alert(message, title)

Shows a modal message box with one button (OK) and blocks until the user acknowledged it. Parameters are optional. Also available as a global.

alert("Hello, world!");

emit(event)

hide()

minimize()

maximize()

off(event)

Removes an event.

on(event, callback)

Adds an event.

raise()

removeEventListener(event)

Alias to window.off.

restore()

show()

Properties

bordered

Enables or disables the window decorations.

brightness

Gets or sets the screen brightness between 0.0 and 1.0.

enableScreenSaver

Enables or disables the screensaver.

flags

fullScreen

innerHeight

Gets or sets the window's height.

innerWidth

Gets or sets the window's width.

opacity

(SDL 2.0.5+)

Gets or sets the window's opacity, between 0.0 and 1.0.

screenX

Gets or sets the distance between the window and the screen's left edge.

screenY

Gets or sets the distance between the window and the screen's top edge.

subsystem

Gets the name of the system it's running on.

title

Gets or sets the window's title.

visible

Events

unload

Fires when the application is about to close (e.g. the user clicked the close button or sent a SIGINT). The callback can return false to prevent the application from quitting.

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.