Lua Differences

From GMod Wiki

Jump to: navigation, search

Contents

Garry's Mod Lua Differences

The Lua engine implemented in Garry's Mod has a few syntactic differences from the original version of Lua.


Name Lua Standard C-Style
Multi-Line Comments --[[ comment ]] /* comment */
Single Line Comments -- comment // comment
And and &&
Or or ||
Not not !
Not-Equal ~= !=


Garry's Mod uses a customised implementation of Lua. It is not standard Lua.



Pros and Cons of C-style Syntax and Lua Syntax

Lua Standard

Pros

  • Intuitive - uses words such as "and" and "or"
  • Compatible with Lua syntax highlighting
  • Compiles inside external Lua interpreters
  • Easier to understand, more natural

Cons

  • Longer wording

C-Style

Pros

  • Coders more proficient with C++, C#, PHP etc might prefer it
  • Shorter, more compact syntax
  • Good practice for people that will want to eventually advance to C++

Cons

  • Editors will need a plugin/changes to understand the new syntax

Summary

Either syntax works fine, it is largely a matter of personal preference.

Highlighter Fixes

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox