<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://ocr.michiyo.me/w/index.php?action=history&amp;feed=atom&amp;title=Lua_conventions</id>
	<title>Lua conventions - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://ocr.michiyo.me/w/index.php?action=history&amp;feed=atom&amp;title=Lua_conventions"/>
	<link rel="alternate" type="text/html" href="https://ocr.michiyo.me/w/index.php?title=Lua_conventions&amp;action=history"/>
	<updated>2026-08-24T13:46:38Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.9</generator>
	<entry>
		<id>https://ocr.michiyo.me/w/index.php?title=Lua_conventions&amp;diff=1348&amp;oldid=prev</id>
		<title>imported&gt;OCDoc Import: Imported from legacy OpenComputers documentation at ocdoc.cil.li</title>
		<link rel="alternate" type="text/html" href="https://ocr.michiyo.me/w/index.php?title=Lua_conventions&amp;diff=1348&amp;oldid=prev"/>
		<updated>2026-08-24T08:08:27Z</updated>

		<summary type="html">&lt;p&gt;Imported from legacy OpenComputers documentation at ocdoc.cil.li&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Lua Code Conventions =&lt;br /&gt;
&lt;br /&gt;
* Be consistent.&lt;br /&gt;
* Indent using spaces, two wide. Do indent properly.&lt;br /&gt;
* Try to limit width of the code to 80 chars.&lt;br /&gt;
* Don&amp;#039;t add spaces between braces/brackets and what&amp;#039;s in them.&lt;br /&gt;
* Do use brackets in functions calls even if it&amp;#039;s not necessary.&lt;br /&gt;
* Name variables for what they are, don&amp;#039;t include type markers in them, i.e. do not use Hungarian notation.&lt;br /&gt;
* Nice to have: sort your requires alphabetically (OCD!)&lt;br /&gt;
* Feel free to comment your code. Any additional memory needed to load your file due to heavy use of comments is released soon after loading is complete.&lt;br /&gt;
* If you have to validate arguments, use the built-in checkArg method. Homogenous error messages are a good thing! Its usage is checkArg(n, value, type1, ...), where n is the number of the argument, value is the value of the argument and type1 and so on are the allowed types for the argument, as retrieved via type(value). The number is used in the error message like so: &amp;quot;bad argument #n (type1 expected, got type(value))&amp;quot;. So for example, to require the first argument to be a number you&amp;#039;d do checkArg(1, arg, &amp;quot;number&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
Bad Code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;function f(sArg1 , ... )&lt;br /&gt;
   assert(type(sArg1)== &amp;quot;string&amp;quot;, &amp;quot;me wants a strign!&amp;quot;)&lt;br /&gt;
    if sArg1 then&lt;br /&gt;
        local nResult = 1&lt;br /&gt;
        --do some more stuff&lt;br /&gt;
        return nResult&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
if  f ( &amp;quot;a&amp;quot; )  ==1 then&lt;br /&gt;
print&amp;quot;asd&amp;quot;&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Good Code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;function f(name, ...)&lt;br /&gt;
  checkArg(1, name, &amp;quot;string&amp;quot;)&lt;br /&gt;
  if name then&lt;br /&gt;
    local result = 1&lt;br /&gt;
    -- We extrapolate the b-spline of the non-euclidean space to&lt;br /&gt;
    -- determine the fraction of potential failures encountered.&lt;br /&gt;
    return result&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
if f(&amp;quot;a&amp;quot;) == 1 then&lt;br /&gt;
  print(&amp;quot;asd&amp;quot;)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
== Contents ==&lt;br /&gt;
&lt;br /&gt;
{{:contents}}&lt;br /&gt;
&lt;/div&gt;</summary>
		<author><name>imported&gt;OCDoc Import</name></author>
	</entry>
</feed>