<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/wiki/Operators?action=history&amp;feed=atom</id>
	<title>Operators - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/wiki/Operators?action=history&amp;feed=atom"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Operators&amp;action=history"/>
	<updated>2026-04-07T06:09:47Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=Operators&amp;diff=48002&amp;oldid=prev</id>
		<title>Walid: Lua Operators</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=Operators&amp;diff=48002&amp;oldid=prev"/>
		<updated>2016-07-06T02:33:44Z</updated>

		<summary type="html">&lt;p&gt;Lua Operators&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 30%; margin: auto&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot;| &lt;br /&gt;
! scope=&amp;quot;col&amp;quot;| Operators&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;row&amp;quot; | Arithmetic&lt;br /&gt;
| style=&amp;quot;text-align:center&amp;quot; | `+´ , `-´ , `*´ , `/´ , `-´ , `^´&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;row&amp;quot;| Relational&lt;br /&gt;
| style=&amp;quot;text-align:center&amp;quot; | `&amp;lt;´ , `&amp;gt;´ , `&amp;lt;=´ , `&amp;gt;=´ , `==´ , `~=´&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;row&amp;quot;| Logical&lt;br /&gt;
| style=&amp;quot;text-align:center&amp;quot; | `and´, `or´, `not´&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;row&amp;quot;| Misc&lt;br /&gt;
| style=&amp;quot;text-align:center&amp;quot; | `..´, `#´&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Arithmetic Operators==&lt;br /&gt;
&lt;br /&gt;
Following table shows all the arithmetic operators supported by Lua language.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 50%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot;| Operator&lt;br /&gt;
|-&lt;br /&gt;
| `+´ (addition) : Adds two operands Ex: 1 + 5 = 6&lt;br /&gt;
|-&lt;br /&gt;
| `-´ (subtraction): Subtracts second operand from the first Ex: 10-30 = -20&lt;br /&gt;
|-&lt;br /&gt;
| `*´ (multiplication): Multiply both operands Ex: 5 * 3 = 15&lt;br /&gt;
|-&lt;br /&gt;
| `/´ (division): Divide numerator by de-numerator Ex: 8 / 2 = 4&lt;br /&gt;
|-&lt;br /&gt;
| `^´ (exponentiation): Exponent Operator takes the exponents Ex: 5 ^ 2 = 25&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local W = 5&lt;br /&gt;
local M = 10&lt;br /&gt;
 &lt;br /&gt;
outputChatBox(W + M) -- Addition: 15&lt;br /&gt;
outputChatBox(W - M) -- Subtraction: -5&lt;br /&gt;
outputChatBox(W * M) -- Multiplication: 50&lt;br /&gt;
outputChatBox(W / M) -- Division: 0.5&lt;br /&gt;
outputChatBox(W^2) -- Exponentiation: 25&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Relational Operators==&lt;br /&gt;
&lt;br /&gt;
Relational operators are supplied which return the boolean values true or false.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 50%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot;| Operator&lt;br /&gt;
|-&lt;br /&gt;
| `==´ (equal to) : Example (5 == 6) false&lt;br /&gt;
|-&lt;br /&gt;
| `~=´ (not equal to) : Example (5 ~= 6) true&lt;br /&gt;
|-&lt;br /&gt;
| `&amp;lt;´ (less than) : Example (5 &amp;lt; 6 ) true&lt;br /&gt;
|-&lt;br /&gt;
| `&amp;gt;´ (greater than) : Example (5 &amp;gt; 6 ) false&lt;br /&gt;
|-&lt;br /&gt;
| `&amp;lt;=´ (less than or equal to) : Example (5 &amp;lt;= 6 ) true&lt;br /&gt;
|-&lt;br /&gt;
| `&amp;gt;=´(greater than or equal to) : Example (5 &amp;gt;= 6 ) false&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local W = 5&lt;br /&gt;
local M = 10&lt;br /&gt;
 &lt;br /&gt;
-- Example 1 : == Equal to&lt;br /&gt;
if( W == M ) then&lt;br /&gt;
   outputChatBox(W..&amp;quot; is equal to &amp;quot;..M )&lt;br /&gt;
else&lt;br /&gt;
   outputChatBox(W..&amp;quot; is not equal to &amp;quot;..M )&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
-- Example 2 : ~= Not equal to&lt;br /&gt;
if( W ~= M ) then&lt;br /&gt;
   outputChatBox(W..&amp;quot; is not equal to &amp;quot;..M )&lt;br /&gt;
else&lt;br /&gt;
   outputChatBox(W..&amp;quot; is equal to &amp;quot;..M )&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
-- Example 3 : &amp;lt; less than&lt;br /&gt;
if ( W &amp;lt; M ) then&lt;br /&gt;
   outputChatBox(W..&amp;quot; is less than &amp;quot;..M )&lt;br /&gt;
else&lt;br /&gt;
   outputChatBox(W..&amp;quot; is not less than &amp;quot;..M )&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
-- Example 4 : Greater than&lt;br /&gt;
if ( W &amp;gt; M ) then&lt;br /&gt;
   outputChatBox(W..&amp;quot; is greater than &amp;quot;..M)&lt;br /&gt;
else&lt;br /&gt;
   outputChatBox(W..&amp;quot; is not greater than &amp;quot;..M )&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
-- Example 5 : &amp;lt;= less than or equal to&lt;br /&gt;
if ( W &amp;lt;= M ) then&lt;br /&gt;
   outputChatBox(W..&amp;quot;is either less than or equal to &amp;quot;..M )&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
-- Example 6 : &amp;gt;= greater than or equal to&lt;br /&gt;
if ( M &amp;gt;= W )&lt;br /&gt;
   outputChatBox(M..&amp;quot; is either greater than  or equal to &amp;quot;..W )&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|These also work on strings (alphabetical order) and other types.}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Logical Operators==&lt;br /&gt;
&lt;br /&gt;
Following table shows all the logical operators supported by Lua language.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 50%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot;| Operator&lt;br /&gt;
|-&lt;br /&gt;
| `and´: (Called Logical AND operator) Example:(true and false) is false&lt;br /&gt;
|-&lt;br /&gt;
| `or´:	(Called Logical OR Operator) Example:(true or false) is true&lt;br /&gt;
|-&lt;br /&gt;
| `not´: (Called Logical NOT Operator) Example: (not true) is false&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Misc Operators==&lt;br /&gt;
&lt;br /&gt;
Also there is Miscellaneous operators supported by Lua Language include concatenation and length.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 50%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! scope=&amp;quot;col&amp;quot;| Operator&lt;br /&gt;
|-&lt;br /&gt;
| `..´ : Concatenates two strings.&lt;br /&gt;
|-&lt;br /&gt;
| `#´  : An unary operator that return the length of the a string or a table.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
W = &amp;quot;Hello&amp;quot;&lt;br /&gt;
M = &amp;quot;Everybody&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
-- Example 1 : Concatenates two strings.&lt;br /&gt;
outputChatBox(W..&amp;quot; &amp;quot;..M) -- Result: Hello Everybody&lt;br /&gt;
 &lt;br /&gt;
-- Example 2:&lt;br /&gt;
outputChatBox(#W) -- Result: 5&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
[[Category:Scripting Concepts]]&lt;/div&gt;</summary>
		<author><name>Walid</name></author>
	</entry>
</feed>