\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{SrGMC} \pdfinfo{ /Title (lua-scripting-5-1.pdf) /Creator (Cheatography) /Author (SrGMC) /Subject (Lua Scripting 5.1 Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{A31A1A} \definecolor{LightBackground}{HTML}{F9F0F0} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Lua Scripting 5.1 Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{SrGMC} via \textcolor{DarkBackground}{\uline{cheatography.com/62984/cs/16090/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}SrGMC \\ \uline{cheatography.com/srgmc} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 13th June, 2018.\\ Updated 13th June, 2018.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Types}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{number} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{string} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{boolean} \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{table} \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{function} \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{userdata} \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{thread} \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{nil} \tn % Row Count 8 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Variable type can be obtained with {\bf{type(variable)}} \newline {\bf{Note:}} Table index starts at 0, but can be extended to 0 or negative numbers} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{4.4793 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Arithmetic Expressions}} \tn % Row 0 \SetRowColor{LightBackground} Sum & + \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} Negation/Subtraction & - \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} Product & * \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} Division & / \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} Modulo & \% \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} Power & \textasciicircum{} \tn % Row Count 6 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{4.4793 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Relational Expressions}} \tn % Row 0 \SetRowColor{LightBackground} Equal to & == \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} Not equal to & \textasciitilde{}= \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} Less than & \textless{} \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} Greater than & \textgreater{} \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} Less than or equal to & \textless{}= \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} Greater than or equal to & \textgreater{}= \tn % Row Count 6 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Logical Operators}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{not} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{and} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{or} \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Even though Lua does not have a Ternary operator (condition ? truevalue : falsevalue), we can use {\emph{and}} and {\emph{or}} to achieve a similar effect: \newline `value = (condition and truevalue) or falsevalue` \newline In this case {\emph{and}} returns truevalue when the condition is true and falsevalue otherwise} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Tables}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Tables are used with the table{[}key{]} syntax \newline % Row Count 1 (+ 1) {\emph{Example:}} \newline % Row Count 2 (+ 1) \textgreater{} t = \{foo="bar"\} -{}- Same as t=\{{[}"foo"{]}="bar"\} \newline % Row Count 3 (+ 1) \textgreater{} t.foo \newline % Row Count 4 (+ 1) bar \newline % Row Count 5 (+ 1) They can also be used as arrays \newline % Row Count 6 (+ 1) a = \{1, 2, 3\} \newline % Row Count 7 (+ 1) But in this case, index starts at 1 \newline % Row Count 8 (+ 1) a = \{{[}0{]}=1, {[}1{]}=2\} \newline % Row Count 9 (+ 1) Tables can be extended to index 0 or even negative numbers \newline % Row Count 11 (+ 2) Table size can be found with: \newline % Row Count 12 (+ 1) \textgreater{} a = \{1, 2, 3\} \newline % Row Count 13 (+ 1) \textgreater{} \# a \newline % Row Count 14 (+ 1) 3% Row Count 15 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Functions and modules}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{Functions}} \newline % Row Count 1 (+ 1) value = {\bf{function}}({\emph{args}}) body {\bf{end}} \newline % Row Count 2 (+ 1) {\bf{function}} functionName({\emph{args}}) body {\bf{end}} \newline % Row Count 3 (+ 1) Functions can be used as arguments: \newline % Row Count 4 (+ 1) {\bf{function}} f({\emph{f2, arg1}}) f2(arg1) {\bf{end}} \newline % Row Count 5 (+ 1) Return skips other code below it \newline % Row Count 6 (+ 1) {\bf{Modules}} \newline % Row Count 7 (+ 1) A common module declaration usually is: \newline % Row Count 8 (+ 1) {\bf{local}} mymodule = \{\} \newline % Row Count 9 (+ 1) {\bf{function}} mymodule.foo() {\bf{print}}({\emph{"bar"}}) {\bf{end}} \newline % Row Count 11 (+ 2) {\bf{return}} mymodule \newline % Row Count 12 (+ 1) As tables can have functions assigned to a key. \newline % Row Count 13 (+ 1) To import it, just do: \newline % Row Count 14 (+ 1) \textgreater{} module = require("mymodule") \newline % Row Count 15 (+ 1) \textgreater{} module.foo() \newline % Row Count 16 (+ 1) bar \newline % Row Count 17 (+ 1) Also, you can make private functions by putting local in front of the function declaration.% Row Count 19 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Math Library}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{math.abs(number)} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{math.acos(radians), math.asin(radians), math.atan(radians)} \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{math.ceil(number), math.floor(number)} \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{math.cos(radians), math.sin(radians), math.tan(radians)} \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{math.deg(radians), math.rad(degrees)} \tn % Row Count 7 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{math.exp(number), math.log(number)} \tn % Row Count 8 (+ 1) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{math.min(num1, num2, ...), math.max(num1, num2, ...)} \tn % Row Count 10 (+ 2) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{math.sqrt(number)} \tn % Row Count 11 (+ 1) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{math.random(), math.random(upper), math.random(lower, upper)} \tn % Row Count 13 (+ 2) % Row 9 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{math.randomseed(seed)} \tn % Row Count 14 (+ 1) % Row 10 \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{math.huge -{}-{\emph{represents infinity}}} \tn % Row Count 15 (+ 1) % Row 11 \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{math.pi} \tn % Row Count 16 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{On trigonometric calculations, the number is expressed as radians. \newline On math.random() lower and upper are inclusive. \newline math.huge can be also represented with -math.huge} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Control Structures}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{{\bf{if/else statement}} \newline % Row Count 1 (+ 1) if (condition1) then \newline % Row Count 2 (+ 1) block \newline % Row Count 3 (+ 1) elseif (condition2) then \newline % Row Count 4 (+ 1) block \newline % Row Count 5 (+ 1) else \newline % Row Count 6 (+ 1) block \newline % Row Count 7 (+ 1) end \newline % Row Count 8 (+ 1) {\bf{while loop}} \newline % Row Count 9 (+ 1) while (condition) do \newline % Row Count 10 (+ 1) block \newline % Row Count 11 (+ 1) end \newline % Row Count 12 (+ 1) {\bf{repeat loop}} \newline % Row Count 13 (+ 1) \textasciicircum{}{\emph{Like while loop, but condition is inverted}}\textasciicircum{} \newline % Row Count 14 (+ 1) repeat \newline % Row Count 15 (+ 1) block \newline % Row Count 16 (+ 1) until (condition) \newline % Row Count 17 (+ 1) {\bf{Numeric for loop}} \newline % Row Count 18 (+ 1) for variable = start, stop, step do \newline % Row Count 19 (+ 1) block \newline % Row Count 20 (+ 1) end \newline % Row Count 21 (+ 1) {\bf{Iterator for loop}} \newline % Row Count 22 (+ 1) for var1, var2, var3 in iterator do \newline % Row Count 23 (+ 1) block \newline % Row Count 24 (+ 1) end% Row Count 25 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.43873 cm} x{2.53827 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Table Library}} \tn % Row 0 \SetRowColor{LightBackground} table.concat(table {[}, sep {[}, i {[}, j{]}{]}{]}) & Concatenate the elements of a table to form a string. Each element must be able to be coerced into a string. \tn % Row Count 6 (+ 6) % Row 1 \SetRowColor{white} \seqsplit{table.foreach(table}, f) & Apply the function f to the elements of the table passed. On each iteration the function f is passed the key-value pair of that element in the table. Apply the function f to the elements of the table passed. On each iteration the function f is passed the key-value pair of that element in the table. {\emph{Deprecated}} \tn % Row Count 22 (+ 16) % Row 2 \SetRowColor{LightBackground} \seqsplit{table.foreachi(table}, f) & Apply the function f to the elements of the table passed. On each iteration the function f is passed the index-value pair of that element in the table. This is similar to table.foreach() except that index-value pairs are passed, not key-value pairs. {\emph{Deprecated}} \tn % Row Count 36 (+ 14) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.43873 cm} x{2.53827 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Table Library (cont)}} \tn % Row 3 \SetRowColor{LightBackground} table.sort(table {[}, comp{]}) & Sort the elements of a table in-place. A comparison function can be provided to customise the element sorting. The comparison function must return a boolean value specifying whether the first argument should be before the second argument in the sequence. \tn % Row Count 13 (+ 13) % Row 4 \SetRowColor{white} table.insert(table, {[}pos,{]} value) & Insert a given value into a table. If a position is given insert the value before the element currently at that position. \tn % Row Count 20 (+ 7) % Row 5 \SetRowColor{LightBackground} table.remove(table {[}, pos{]}) & Remove an element from a table. If a position is specified the element at that the position is removed. The remaining elements are reindexed sequentially and the size of the table is updated to reflect the change. The element removed is returned by this function. \tn % Row Count 34 (+ 14) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{table.sort() example:}} \newline \textgreater{} t = \{ 3,2,5,1,4 \} \newline \textgreater{} table.sort(t, function(a,b) return a\textless{}b end) \newline \textgreater{} = table.concat(t, ", ") \newline 1, 2, 3, 4, 5} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{String}} \tn % Row 0 \SetRowColor{LightBackground} string.byte(s {[}, i {[}, j{]}{]}) & Return the numerical code the i-th through j-th character of the string passed. \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} string.char(i1, i2, ...) & Generate a string representing the character numerical code passed as arguments. \tn % Row Count 8 (+ 4) % Row 2 \SetRowColor{LightBackground} string.find(s, pattern {[}, index {[}, plain{]}{]}) & Find the first occurrence of the pattern in the string passed \tn % Row Count 12 (+ 4) % Row 3 \SetRowColor{white} string.format(s, e1, e2, ...) & Create a formatted string from the format and arguments provided. This is similar to the printf("format",...) function in C. \tn % Row Count 19 (+ 7) % Row 4 \SetRowColor{LightBackground} string.gsub(s, pattern, replace {[}, n{]}) & Used simply it can replace all instances of the pattern provided with the replacement. A pair of values is returned, the modified string and the number of substitutions made. The optional fourth argument n can be used to limit the number of substitutions made \tn % Row Count 32 (+ 13) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{String (cont)}} \tn % Row 5 \SetRowColor{LightBackground} string.len(s) & Return the length of the string passed. \tn % Row Count 2 (+ 2) % Row 6 \SetRowColor{white} string.lower(s) & Make all the upper case characters lower case. \tn % Row Count 5 (+ 3) % Row 7 \SetRowColor{LightBackground} string.upper(s) & Make all the lower case characters upper case. \tn % Row Count 8 (+ 3) % Row 8 \SetRowColor{white} string.match (s, pattern {[}, index{]}) & Extract substrings by matching patterns. \tn % Row Count 10 (+ 2) % Row 9 \SetRowColor{LightBackground} string.rep(s, n) & Generate a string which is n copies of the string passed concatenated together. \tn % Row Count 14 (+ 4) % Row 10 \SetRowColor{white} string.reverse(s) & Reverses a string. \tn % Row Count 15 (+ 1) % Row 11 \SetRowColor{LightBackground} string.sub(s, i {[}, j{]}) & Return a substring of the string passed. The substring starts at i. If the third argument j is not given, the substring will end at the end of the string. If the third argument is given, the substring ends at and includes j. \tn % Row Count 27 (+ 12) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{All functions can be used directly in string by changing string. to s:, s being the string \newline {\emph{Example}}: \newline `string.reverse("Test")` \newline `"Test":reverse()"`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Classes. Table based}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{local Person = \{\} \newline Person.\_\_index = Person \newline \newline function Person.new(name, surname) \newline local self = setmetatable(\{\}, Person) \newline self.name = name \newline self.surname = surname \newline return self \newline end \newline \newline function Person.setName(self, name) \newline self.name = name \newline end \newline \newline function Person.getName(self) \newline return self.name \newline end \newline \newline function Person.setSurname(self, surname) \newline self.surname = surname \newline end \newline \newline function Person.getSurname(self) \newline return self.surname \newline end \newline \newline return Person \newline \newline -{}- Import with ClassName = require("classname") \newline -{}- Use with local i = ClassName.init(params)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Faster to create. Does not have private attributes} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Classes. Closure/Instance Based}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{local function MyClass(init) \newline local self = \{ \newline public\_field = 0 \newline \} \newline \newline local private\_field = init \newline \newline function self.foo() \newline return private\_field \newline end \newline \newline function self.bar() \newline private\_field = private\_field + 1 \newline end \newline \newline return self \newline end \newline \newline return MyClass \newline \newline -{}- Import with MyClass = require("MyClass") \newline -{}- Use with local i = MyClass(init)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Can have private attributes. Slower to create} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}