Garry's Mod Wiki

Revision Difference

Specific_Operators#527967

<cat>Dev.GettingStarted</cat> Garry's Mod features a set of non-default operators and aliases of already existing ones. The implemented operators include⤶ The implemented operators include:⤶ Operator | -----------| | `continue` | <warning>`continue` may work incorrectly, consider using `goto`</warning> <example> <description>Use `goto` for the same functionality as `continue`, this example loops through all the players and kills all superadmins then respawns them.</description> <code> for k, v in pairs( player.GetAll() ) do for _, v in ipairs( player.GetAll() ) do if not v:IsSuperAdmin() then goto cont-- skips any iterations where the player is not superadmin goto cont -- skips any iterations where the player is not superadmin end v:Kill() v:Spawn() ::cont:: end </code> </example> The implemented aliases are as following⤶ The implemented aliases are as following:⤶ Operator | Alias | ----------|------- | | `and` | `&&` | | `or` | `||` | | `not` | `!` | | `~=` | `!=` | | `--[[ ]]` | `/* */` | | `--` | `//` | ⤶ <warning>⤶ It is suggested to avoid using the custom operators if you wish to use your scripts outside of Garry's Mod, as they are incompatible with standard Lua.⤶ </warning>⤶ ⤶ <warning>It is suggested to avoid using the custom operators if you wish to use your scripts outside of Garry's Mod, as they are incompatible with standard Lua.</warning>⤶