Skip to content

Globals

Global functions defined in NutScript.

Some functions exist in the global realm (_G) instead of being part of a class or module.

Networking global functions

setNetVar (key, value, receiver)
setNetVar

Sets a global network variable. Broadcasts the variable to specified receivers.

Parameters:

string key Name of the variable

vararg value Value to assign

Client receiver optional Client or list of clients to receive the update

getNetVar (key, default)
getNetVar

Gets a global network variable. Returns default value if key does not exist. The clientside version of the function can only return data that was previously networked to the client.

Parameters:

string key Variable name

vararg default optional Default fallback value

Returns:

The global value or the default

Language functions

L (key, client, ...)
L

Gets localized string with formatting (server version)

Parameters:

string key Language string key

Client client Target player for language preference

vararg ... Format arguments

Returns:

string Formatted localized string

Or

string Original key if translation missing

Usage:

    L("welcomeMessage", player, player:Name())
    

L2 (key, client, ...)
L2

Gets localized string only if exists (server version)

Parameters:

string key Language string key

Client client Target player for language preference

vararg ... Format arguments

Returns:

string Formatted string if translation exists

Or

nil If no translation found

L3 (key, langKey, ...)
L3

Gets localized string with explicit language (server version)

Parameters:

string key Language string key

string langKey Specific language to use

vararg ... Format arguments

Returns:

string Formatted localized string

Or

string Original key if translation missing

L (key, ...)
L

Gets localized string with formatting (client version)

Parameters:

string key Language string key

vararg ... Format arguments

Returns:

string Formatted localized string

Or

string Original key if translation missing

Usage:

    L("welcomeMessage", LocalPlayer():Name())
    

L2 (key, ...)
L2

Gets localized string only if exists (client version)

Parameters:

string key Language string key

vararg ... Format arguments

Returns:

string Formatted string if translation exists

Or

nil If no translation found

LangFileStruct
LangFileStruct

Language File Structure: Each language file should return:

Fields:

vararg NAME Display name of the language

vararg LANGUAGE Table of key-value string pairs

Usage:

    1
    2
    3
    4
    5
    LANGUAGE = {
        welcome = "Welcome, %s!",
        goodbye = "Goodbye!"
    }
    NAME = "English"