Module ScreenUnit

Screen units can display any HTML code or text message, and you can use them to create visually interactive feedback for your running Lua script by connecting one or more of them to your control unit.

Element class:

  • ScreenUnit: Basic and transparent screens
  • ScreenSignUnit: Signs

Documentation for the renderScript is separate.

Note: The max size of screen content is 50,000 characters. Any calls to set or add content that result in the screen exceeding this will silently fail.

Extends: Element > ElementWithState > ElementWithToggle

See also:

Functions

activate () Switch on the screen.
deactivate () Switch off the screen.
isActive () Checks if the screen is on.
addText (x, y, fontSize, text) Deprecated: Displays the given text at the given coordinates in the screen, and returns an ID to move it later.
setCenteredText (text) Displays the given text centered in the screen with a font to maximize its visibility.
setHTML (html) Deprecated: Set the whole screen HTML content (overrides anything already set).
setRenderScript (script) Set the screen render script, switching the screen to native rendering mode.
setScriptInput (params) Defines the input of the screen rendering script, which will be automatically defined during the execution of Lua.
clearScriptOutput () Set the screen render script output to the empty string.
getScriptOutput () Get the screen render script output.
addContent (x, y, html) Deprecated: Displays the given HTML content at the given coordinates in the screen, and returns an ID to move it later.
setSVG (svg) Deprecated: Displays SVG code (anything that fits within a <svg> section), which overrides any preexisting content.
resetContent (id, html) Deprecated: Update the element with the given ID (returned by addContent) with a new HTML content.
deleteContent (id) Deprecated: Delete the element with the given ID (returned by addContent).
showContent (id, state) Deprecated: Update the visibility of the element with the given ID (returned by addContent).
moveContent (id, x, y) Deprecated: Move the element with the given id (returned by addContent) to a new position in the screen.
getMouseX () Returns the x-coordinate of the position pointed at in the screen.
getMouseY () Returns the y-coordinate of the position pointed at in the screen.
getMouseState () Returns the state of the mouse click.
clear () Deprecated: Clear the screen.
setSignalIn (plug, state) Set the value of a signal in the specified IN plug of the element.
getSignalIn (plug) Return the value of a signal in the specified IN plug of the element.
EVENT_mouseDown (x, y) Deprecated: Event: Emitted when the player starts a click on the screen unit.
EVENT_onMouseDown (x, y) Event: Emitted when the player starts a click on the screen.
EVENT_mouseUp (x, y) Deprecated: Event: Emitted when the player releases a click on the screen unit.
EVENT_onMouseUp (x, y) Event: Emitted when the player releases a click on the screen unit.
EVENT_onOutputChanged (output) Event: Emitted when the output of the screen is changed.


Functions

activate ()
Switch on the screen.
deactivate ()
Switch off the screen.
isActive ()
Checks if the screen is on.

Returns:

    0/1 1 if the screen is on.
addText (x, y, fontSize, text)
Deprecated: Displays the given text at the given coordinates in the screen, and returns an ID to move it later.

This method is deprecated: Lua rendering on the screen or setRenderScript(script) should be used instead

Parameters:

  • x float Horizontal position, as a percentage (between 0 and 100) of the screen width.
  • y float Vertical position, as a percentage (between 0 and 100) of the screen height.
  • fontSize float Text font size, as a percentage (between 0 and 100) of the screen width.
  • text string The text to display.

Returns:

    An integer ID that can be used later to update/remove the added element.

See also:

setCenteredText (text)
Displays the given text centered in the screen with a font to maximize its visibility.

Parameters:

  • text string The text to display.
setHTML (html)
Deprecated: Set the whole screen HTML content (overrides anything already set).

This method is deprecated: Lua rendering on the screen or setRenderScript(script) should be used instead

Parameters:

  • html string The HTML content to display.

See also:

setRenderScript (script)
Set the screen render script, switching the screen to native rendering mode.

Parameters:

  • script string The Lua render script.
setScriptInput (params)
Defines the input of the screen rendering script, which will be automatically defined during the execution of Lua.

Parameters:

  • params string A string that can be retrieved by calling getInput in a render script.

See also:

clearScriptOutput ()
Set the screen render script output to the empty string.

See also:

getScriptOutput ()
Get the screen render script output.

Returns:

    string The contents of the last render script setOutput call, or an empty string.

See also:

addContent (x, y, html)
Deprecated: Displays the given HTML content at the given coordinates in the screen, and returns an ID to move it later.

This method is deprecated: Lua rendering on the screen or setRenderScript(script) should be used instead

Parameters:

  • x float Horizontal position, as a percentage (between 0 and 100) of the screen width.
  • y float Vertical position, as a percentage (between 0 and 100) of the screen height.
  • html string The HTML content to display, which can contain SVG elements to make drawings.

Returns:

    An integer ID that can be used later to update/remove the added element.

See also:

setSVG (svg)
Deprecated: Displays SVG code (anything that fits within a <svg> section), which overrides any preexisting content.

This method is deprecated: Lua rendering on the screen or setRenderScript(script) should be used instead

Parameters:

  • svg string The SVG content to display, which fits inside a 1920x1080 canvas.

See also:

resetContent (id, html)
Deprecated: Update the element with the given ID (returned by addContent) with a new HTML content.

This method is deprecated: Lua rendering on the screen or setRenderScript(script) should be used instead

Parameters:

  • id int An integer ID that is used to identify the element in the screen. Methods such as addContent return the ID that you can store to use later here.
  • html string The HTML content to display, which can contain SVG elements to make drawings.

See also:

deleteContent (id)
Deprecated: Delete the element with the given ID (returned by addContent).

This method is deprecated: Lua rendering on the screen or setRenderScript(script) should be used instead

Parameters:

  • id int An integer ID that is used to identify the element in the screen. Methods such as addContent return the ID that you can store to use later here.

See also:

showContent (id, state)
Deprecated: Update the visibility of the element with the given ID (returned by addContent).

This method is deprecated: Lua rendering on the screen or setRenderScript(script) should be used instead

Parameters:

  • id int An integer ID that is used to identify the element in the screen. Methods such as addContent return the ID that you can store to use later here.
  • state 0/1 0 = invisible, 1 = visible.

See also:

moveContent (id, x, y)
Deprecated: Move the element with the given id (returned by addContent) to a new position in the screen.

This method is deprecated: Lua rendering on the screen or setRenderScript(script) should be used instead

Parameters:

  • id int An integer ID that is used to identify the element in the screen. Methods such as addContent return the ID that you can store to use later here.
  • x float Horizontal position, as a percentage (between 0 and 1) of the screen width.
  • y float Vertical position, as a percentage (between 0 and 1) of the screen height.

See also:

getMouseX ()
Returns the x-coordinate of the position pointed at in the screen.

Returns:

    float The x-position as a percentage (between 0 and 1) of screen width; -1 if nothing is pointed at.
getMouseY ()
Returns the y-coordinate of the position pointed at in the screen.

Returns:

    float The y-position as a percentage (between 0 and 1) of screen height; -1 if nothing is pointed at.
getMouseState ()
Returns the state of the mouse click.

Returns:

    0/1 1 if the mouse is pressed, otherwise 0.
clear ()
Deprecated: Clear the screen.

This method is deprecated: Lua rendering on the screen or setRenderScript(script) should be used instead

See also:

setSignalIn (plug, state)
Set the value of a signal in the specified IN plug of the element.

Valid plug names are:

  • "in" for the in signal (seems to have no actual effect when modified this way).

Parameters:

  • plug string A valid plug name to set.
  • state 0/1 The plug signal state
getSignalIn (plug)
Return the value of a signal in the specified IN plug of the element.

Valid plug names are:

  • "in" for the in signal.

Parameters:

  • plug string A valid plug name to query.

Returns:

    0/1 The plug signal state
EVENT_mouseDown (x, y)
Deprecated: Event: Emitted when the player starts a click on the screen unit.

Note: This is documentation on an event handler, not a callable method.

This event is deprecated: EVENT_onMouseDown should be used instead.

Parameters:

  • x float X-coordinate of the click in percentage of the screen width.
  • y float Y-coordinate of the click in percentage of the screen height.

See also:

EVENT_onMouseDown (x, y)
Event: Emitted when the player starts a click on the screen.

Note: This is documentation on an event handler, not a callable method.

Parameters:

  • x float X-coordinate of the click in percentage (between 0 and 1) of the screen width.
  • y float Y-coordinate of the click in percentage (between 0 and 1) of the screen height.
EVENT_mouseUp (x, y)
Deprecated: Event: Emitted when the player releases a click on the screen unit.

Note: This is documentation on an event handler, not a callable method.

This event is deprecated: EVENT_onMouseUp should be used instead.

Parameters:

  • x float X-coordinate of the click in percentage of the screen width.
  • y float Y-coordinate of the click in percentage of the screen height.

See also:

EVENT_onMouseUp (x, y)
Event: Emitted when the player releases a click on the screen unit.

Note: This is documentation on an event handler, not a callable method.

Parameters:

  • x float X-coordinate of the click in percentage (between 0 and 1) of the screen width.
  • y float Y-coordinate of the click in percentage (between 0 and 1) of the screen height.
EVENT_onOutputChanged (output)
Event: Emitted when the output of the screen is changed.

Note: This is documentation on an event handler, not a callable method.

Parameters:

  • output string The output string of the screen.
generated by LDoc 1.5.0 Last updated 2023-09-04 19:09:50