website is under construction
Lumen

System

Two small modules for talking to the machine and to the engine itself: system for the clipboard, the browser, and the power supply, and lumen for quitting and frame pacing.

The system Module

Methods

MethodWhat it does
getClipboardText()Returns the clipboard's contents as a string.
setClipboardText(text)Puts a string on the clipboard.
openUrl(url)Opens a URL in the player's browser. http and https only.
getPowerInfo()Battery state, as [state, percent, seconds].

getPowerInfo() returns a state of 'unknown', 'battery', 'nobattery', 'charging', or 'charged', the charge as a percentage, and the seconds of charge remaining. Percent and seconds are -1 when the system cannot tell.

power = system.getPowerInfo()

if (power[0] == 'battery') {
  if (power[1] < 15) {
    game.showLowBatteryWarning = true
  }
}

Properties

PropertyValue
system.osdarwin, linux, windows, and so on.
system.processorCountLogical CPUs the machine has.

The lumen Module

Methods

MethodWhat it does
quit()Ends the game.
setTargetFps(n)Caps the frame rate. 0 uncaps it.
getTargetFps()The current cap.

The default is 60. An uncapped game runs as fast as it can, which is what window.setVsync() is usually the better answer to.

function keypressed(key, isRepeat) {
  if (key == 'escape') {
    lumen.quit()
  }
}

quit() runs the quit() callback if your game defines one, so an unsaved-changes prompt gets its chance either way.

Properties

PropertyValue
lumen.versionThe engine's version.