Options
All
  • Public
  • Public/Protected
  • All
Menu

The game world

Hierarchy

  • GameWorld

Index

Methods

addUI

  • Add a new global UI element in the world

    Parameters

    Returns void

boxOverlap

  • Find all objects that would collide with a box

    Parameters

    • position: Vector

      Center of the box

    • extent: Vector

      Dimensions of the box (from center to on of the corners)

    • Optional orientation: Rotator

      Orientation of the box

    Returns GameObject[]

boxTrace

  • Find all object hits with a box that is moved along a line, ordered by distance to start

    Parameters

    • start: Vector

      Starting point of the box

    • end: Vector

      End point of box movement

    • extent: Vector

      Dimensions of the box (from center to on of the corners)

    • Optional orientation: Rotator

      Orientation of the box

    Returns TraceHit[]

broadcastChatMessage

  • broadcastChatMessage(message: string, color: Color): void
  • Send a chat message to all players

    Parameters

    • message: string
    • color: Color

    Returns void

capsuleOverlap

  • Find all objects that would collide with a capsule

    Parameters

    • position: Vector

      Center of the capsule

    • extent: Vector

      Dimensions of the capsule (from center to one of the corners of the surrounding box)

    • Optional orientation: Rotator

      Orientation of the capsule

    Returns GameObject[]

capsuleTrace

  • Find all objects hits with a capsule that is moved along a line, ordered by distance to start

    Parameters

    • start: Vector

      Starting point of the capsule

    • end: Vector

      End point of the capsule movement

    • extent: Vector

      Dimensions of the capsule

    • Optional orientation: Rotator

      Orientation of the capsule

    Returns TraceHit[]

createObjectFromJSON

  • Create a new object from a JSON string

    Parameters

    • jsonString: string

      String containing Json representation of an object (can be obtained by calling toJSONString() on an object)

    • position: Vector

      Starting position

    Returns GameObject

createObjectFromTemplate

  • Create a new object from a template

    Parameters

    • templateId: string

      Template GUID for the new object

    • position: Vector

      Starting position

    Returns GameObject

drawDebugBox

  • drawDebugBox(center: Vector, extent: Vector, orientation: Rotator, color: Color, duration: number, thickness?: number): void
  • Draw a box in 3d space. The box will only be visible on for the host!

    Parameters

    • center: Vector

      The center of the box

    • extent: Vector

      Maximum point of the box

    • orientation: Rotator

      The rotation of the box

    • color: Color

      Color of the box. Alpha value is not used.

    • duration: number

      Amount of time in seconds to show the box. Can be 0 to show for one frame only.

    • Optional thickness: number

      Thickness of the lines. One pixel thick if 0, cm thickness for values > 0.

    Returns void

drawDebugLine

  • drawDebugLine(start: Vector, end: Vector, color: Color, duration: number, thickness?: number): void
  • Draw a line in 3d space. The line will only be visible on for the host!

    Parameters

    • start: Vector

      Starting point of the line

    • end: Vector

      End point of the line

    • color: Color

      Color of the line. Alpha value is not used.

    • duration: number

      Amount of time in seconds to show the line. Can be 0 to show for one frame only

    • Optional thickness: number

      Thickness of the line. One pixel thick if 0, cm thickness for values > 0.

    Returns void

drawDebugPoint

  • drawDebugPoint(position: Vector, size: number, color: Color, duration: number): void
  • Draw a point. The point will only be visible on for the host!

    Parameters

    • position: Vector

      Position of the point

    • size: number

      Size of the point in cm

    • color: Color

      Color of the point. Alpha value is not used.

    • duration: number

      Amount of time in seconds to show the point. Can be 0 to show for one frame only.

    Returns void

drawDebugSphere

  • drawDebugSphere(position: Vector, radius: number, color: Color, duration: number, thickness?: number): void
  • Draw a point. The sphere will only be visible on for the host!

    Parameters

    • position: Vector

      Position of the point

    • radius: number
    • color: Color

      Color of the sphere. Alpha value is not used.

    • duration: number

      Amount of time in seconds to show the point. Can be 0 to show for one frame only.

    • Optional thickness: number

      Thickness of the lines. One pixel thick if 0, cm thickness for values > 0.

    Returns void

getAllObjects

getAllPlayers

getExecutionReason

  • getExecutionReason(): string
  • Used while executing the global script to determine why it was executed. Possible return values:
    "ScriptReload" - The script was reloaded, for example because it was set in the session options, or because the scripting environment was reset
    "StateLoad" - A game state that has the script set as global script was loaded
    "" - If called at other times

    Returns string

getGameTime

  • getGameTime(): number
  • Return the time in seconds since the game session was started

    Returns number

getObjectById

  • Return the game object with the specified Id

    Parameters

    • objectId: string

      The unique id of the object

    Returns GameObject

getObjectGroupIds

  • getObjectGroupIds(): number[]
  • Return an array of all currently used object group ids. Objects with the same group id are always picked up together.

    Returns number[]

getObjectsByGroupId

  • getObjectsByGroupId(groupID: number): GameObject[]
  • Return an array of all objects with a given object group id.

    Parameters

    • groupID: number

    Returns GameObject[]

getPlayerBySlot

  • getPlayerBySlot(slot: number): Player
  • Return the player occupying the specified slot

    Parameters

    • slot: number

      The player slot (0-9)

    Returns Player

getSavedData

  • getSavedData(): string

getUIs

  • Get an array of all global UI elements. Modifying the array won't change the actual UIs, use setUI to update.

    Returns UIElement[]

lineTrace

  • Find all object hits on the given line, ordered by distance to start

    Parameters

    • start: Vector

      Starting point of the line

    • end: Vector

      End point of the line

    Returns TraceHit[]

reloadScripts

  • reloadScripts(): void
  • Reload all scripts: global script and all object scripts

    Returns void

removeUI

  • removeUI(index: number): void
  • Remove a global UI element.

    Parameters

    • index: number

      The index of the UI element to remove

    Returns void

resetScripting

  • resetScripting(): void
  • Reset scripting environment and reload all scripts

    Returns void

setSavedData

  • setSavedData(data: string): void
  • Set the data that will stored in save game states. The data is available using getSavedData when the global script is run after loading a save state. Try to keep this data small and don't change it frequently, it needs to be sent over the network to all clients.

    Parameters

    • data: string

      Data to store, maximum length 1023 characters

    Returns void

setUI

  • setUI(index: number, element: UIElement): void
  • Replace a global UI element. Will not do anything if called with an index that doesn't have a UI element. You can also use this function when you update an UIElement (for example by changing the position or size), simply set it to its previous index.

    Parameters

    Returns void

sphereOverlap

  • Find all objects that would collide with a sphere

    Parameters

    • position: Vector

      Center of the sphere

    • radius: number

      Radius of the sphere

    Returns GameObject[]

sphereTrace

  • Find all objects hits with a sphere that is moved along a line, ordered by distance to start

    Parameters

    • start: Vector

      Starting point of the sphere

    • end: Vector

      End point of the sphere movement

    • radius: number

      Radius of the sphere

    Returns TraceHit[]

startDebugMode

  • startDebugMode(port?: number): void
  • Start debug mode on the given port. You can use the Chrome DevTools or the Visual Studio Code debugger to connect to the specified port and debug your scripts. For example, with port 9229 (the default), open the following URL to open the DevTools: devtools://devtools/bundled/inspector.html?v8only=true&ws=localhost:9229 For Visual Studio Code, add the following to your debug configurations: { "name": "Inspector", "type": "node", "protocol": "inspector", "request": "attach", "address": "localhost", "port": 9229 }

    Parameters

    • Optional port: number

    Returns void