• Studio

  • Bots

  • Web API

  • Designer Resources

  • Host Resources

  • Overview

    Globals

    In Lua scripting, Globals are essential values or variables that can be accessed from any part of the script without the need to pass them explicitly. They are context-specific and readily available. On the other hand, a Service in Lua script is like a toolbox of static functions that offer convenient utilities for developers to use in their scripts.

    Properties

    ServerAndClient

    The 'self' property is used to access the current script's instance. This is always the owning script of the object as a Class.LuaBehaviour. This is the primary way to get many of the core Unity MonoBehaviour methods and properties like self.gameObject, self:Update and self:OnTriggerEnter. It is highly recommended to familiarize yourself with the Class.LuaBehaviour documentation to understand how to use the 'self' property.

    The 'client' property is used to access the current client instance. This is useful for when you want to access the client's information like the client.localPlayer property or client.PlayerConnected event. Read the Class.GameClient documentation to learn more.

    ServerOnly

    The 'server' property is used to access the current server instance. This is useful for when you want to access the server' information like the server.PlayerConnected event. Read the Class.GameServer documentation to learn more.

    ServerAndClient

    The 'scene' property is used to access the currently active scene.

    Methods

    ServerAndClient

    Defers the execution of a function to the next frame. This is useful for when you want to run a function after the current frame has finished.

    Parameters

    callback

    function

    The function to run in the next frame.

    Returns

    void

    ServerAndClient

    Gets a 'Module' typed script by name as a singleton behaviour, giving access to the hierarchy it is within.

    Using the require method to retrieve a module will automatically load the singleton instance of the behaviour. This is equivalent to using Find and GetComponent to retrieve the behaviour.

    Parameters

    path

    string

    The script name of the module to load.

    Returns

    LuaBehaviour

    The module that was loaded.

    ServerAndClient

    Gets the string representation of the type of the object. This is useful for debugging and logging as well as learning about what types are being returned by complex methods.

    Returns

    string

    The Type of the object. In question.

    ServerAndClient

    Gets the string representation of the object if one has defined one. This is useful for debugging and logging.

    Returns

    string

    PocketWorlds Icon

    © 2024 Pocket Worlds. All rights reserved.