Page tree
Skip to end of metadata
Go to start of metadata



Introduced in

Version:3.5

Description

Description:

Protects a global variable (or function) from being overwritten.

If an attempt is made to overwrite the protected variable, an error message is shown at the top of the screen.

Syntax

Syntax:protect variableName
Parameters:
  • variableName: String - Name of variable or function to protect.
Return Value:Boolean - If true, then protection was successful.

Examples

Examples:

// Definition of global variable and function
myGlobalVar = "original";
myGlobalFunc = {player sidechat "I am protected"};

// Protect both
protect "myGlobalVar";
protect "myGlobalFunc";

// Attempting to overwrite them will cause an error message, but nothing is overwritten
myGlobalVar = "modified";
myGlobalFunc = {player sidechat "overwritten"};

player sidechat myGlobalVar; // Outputs the initial value of "original"
[] call myGlobalFunc; // Runs the initial function, showing "I am protected"

Additional Information

See also: isProtected, unprotect
Multiplayer:
Problems:

Notes