<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://aznot.com/index.php?action=history&amp;feed=atom&amp;title=OpenWest_2014%2FLua</id>
	<title>OpenWest 2014/Lua - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://aznot.com/index.php?action=history&amp;feed=atom&amp;title=OpenWest_2014%2FLua"/>
	<link rel="alternate" type="text/html" href="https://aznot.com/index.php?title=OpenWest_2014/Lua&amp;action=history"/>
	<updated>2026-04-30T05:52:31Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://aznot.com/index.php?title=OpenWest_2014/Lua&amp;diff=92&amp;oldid=prev</id>
		<title>Kenneth at 15:10, 17 May 2014</title>
		<link rel="alternate" type="text/html" href="https://aznot.com/index.php?title=OpenWest_2014/Lua&amp;diff=92&amp;oldid=prev"/>
		<updated>2014-05-17T15:10:18Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Script up your application with Lua!&lt;br /&gt;
: Ryan Erickson (@ryan_erickson)&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Come learn about Lua, the embeddable language that&amp;#039;s used in everything from game scripting to Wikipedia, in mobile to web development. &lt;br /&gt;
In this presentation, I&amp;#039;ll give a short introduction to Lua, how it can be used to extend a C/C++ application, to allow complex scripting without losing performance. I&amp;#039;ll also show some interesting Lua language features.&lt;br /&gt;
Lastly, I&amp;#039;ll give a live demonstration of the ease of embedding Lua into a C application.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Script up your application with Lua&lt;br /&gt;
* Ryan Erickson&lt;br /&gt;
* http://www.untestedhacks.com&lt;br /&gt;
* Works at Control4&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ryan&amp;#039;s home automation - http://ericksonfamily.com/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Programming Language Lua - http://www.lua.org/&lt;br /&gt;
&lt;br /&gt;
Lua: getting started - http://www.lua.org/start.html&lt;br /&gt;
&lt;br /&gt;
Installation:&lt;br /&gt;
 yum install lua&lt;br /&gt;
&lt;br /&gt;
 curl -R -O http://www.lua.org/ftp/lua-5.2.3.tar.gz&lt;br /&gt;
 tar zxf lua-5.2.3.tar.gz&lt;br /&gt;
 cd lua-5.2.3&lt;br /&gt;
 make linux test&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
History:&lt;br /&gt;
* lua.org&lt;br /&gt;
* created in 1993 at PUC-RIO&lt;br /&gt;
* Predecessors: DEL and Sol (merged to Lua)&lt;br /&gt;
* Lua is Portuguese for Moon, not an acronym (play on words from Sol)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Focus:&lt;br /&gt;
* Simplicity for non-programmer audience&lt;br /&gt;
* Portability&lt;br /&gt;
* Designed to be easily embedded, extended&lt;br /&gt;
* Clean ANSI C code&lt;br /&gt;
* Garbage Collected&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Why:&lt;br /&gt;
* Size (tiny) &amp;lt; 100kb DLL/LIB&lt;br /&gt;
* Runs on mobile / embedded devices&lt;br /&gt;
* Performance - interpreted faster than Pyuthon, Ruby, Perl, PHP&lt;br /&gt;
** Need faster? LuaJIT&lt;br /&gt;
** LuaJIT is C++ / Java 6 territory (luajit.org)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Momentum:&lt;br /&gt;
* Used a lot in games&lt;br /&gt;
* Adobe Lightroom and Photoshop&lt;br /&gt;
* First interpreted lanugage allowed on iOS&lt;br /&gt;
* Angry Birds / World of Warcraft&lt;br /&gt;
* Control4 uses&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Safety:&lt;br /&gt;
* Code runs in sandbox&lt;br /&gt;
* Embedder chooses which modules to expose&lt;br /&gt;
* Host application can provide APIs / primitives to Lua engine&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Language:&lt;br /&gt;
* Dynamically typed&lt;br /&gt;
* Whitespace not significant&lt;br /&gt;
** spaces, linebreaks, tabs, what you like&lt;br /&gt;
* Semicolons not required, and discouraged&lt;br /&gt;
* single line comments&lt;br /&gt;
* variables are global by default, &amp;#039;local&amp;#039; keyword&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Types:&lt;br /&gt;
* number, string, boolean, nil, table, function, userdata&lt;br /&gt;
* numbers are double by default&lt;br /&gt;
* can represent floats and integers&lt;br /&gt;
* no i++, i+=2.  use i =i +1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Strings:&lt;br /&gt;
* single/double quote&lt;br /&gt;
* backslash to escape&lt;br /&gt;
* string concatenation uses &amp;#039;..&amp;#039; (not +)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
nil:&lt;br /&gt;
* empty value&lt;br /&gt;
* evaluates to false&lt;br /&gt;
* frees item for garbage collection&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
tables:&lt;br /&gt;
* lua&amp;#039;s single data structure&lt;br /&gt;
* simultaneous array and hashmap&lt;br /&gt;
 a = {&amp;quot;apple&amp;quot;, &amp;quot;banana&amp;quot;}&lt;br /&gt;
 b = {lua = &amp;quot;cool&amp;quot;, java = &amp;quot;sucks&amp;quot;}&lt;br /&gt;
 c = a&lt;br /&gt;
 print(c[3], b.fred, b.[&amp;quot;java&amp;quot;], a.grape)&lt;br /&gt;
   # orange 3 sucks nul&lt;br /&gt;
* arrays in Lua are 1 based&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Comments:&lt;br /&gt;
 -- this is a comment&lt;br /&gt;
 --[[ this is a multi&lt;br /&gt;
 line comment ]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Functions:&lt;br /&gt;
* first class objects&lt;br /&gt;
 function add(a, b)&lt;br /&gt;
    print(a + b)&lt;br /&gt;
 end&lt;br /&gt;
 multiply = function(a, b) print(a * b) end&lt;br /&gt;
 plus = add&lt;br /&gt;
 plus(3,5)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Control:&lt;br /&gt;
 if ... then ... elseif ... else ... End&lt;br /&gt;
 do&lt;br /&gt;
   print(&amp;quot;one&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
 for i = 1, 10 do print(i) end&lt;br /&gt;
 for k, v in pairs({&amp;quot;}} ???&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
C Programmer Hangups:&lt;br /&gt;
* no curly braces - uses begin... end&lt;br /&gt;
* No +=, ++&lt;br /&gt;
* Not equals is &amp;quot;~=&amp;quot;&lt;br /&gt;
* Not is &amp;quot;not&amp;quot;&lt;br /&gt;
* arrays start at 1&lt;br /&gt;
* #array is not always right (if empty items in the middle)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
C interface API&lt;br /&gt;
* set of functions allow C to interact with Lua&lt;br /&gt;
* functions to read/write lua global variables&lt;br /&gt;
* functions to call lua functions&lt;br /&gt;
* functions to register c functions to call within lua&lt;br /&gt;
* stack based parameter passing&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Book:&lt;br /&gt;
* &amp;quot;Programming in Lua&amp;quot; - http://lua.org/pil&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reference PDF:&lt;br /&gt;
* http://lua-users.org/wiki/LuaShortReference&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Demo:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-- comment&lt;br /&gt;
print(&amp;quot;test&amp;quot; .. os.date())&lt;br /&gt;
&lt;br /&gt;
function rirc(user, message)&lt;br /&gt;
  local no_err, errmsg = pcall(parseIRC, user, message)&lt;br /&gt;
  if (no_error == false) then SendIRC(&amp;quot;ryan&amp;quot;, errmsg) end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function parseIRC(user, message)&lt;br /&gt;
  message = message:gsub(&amp;quot;%s&amp;quot;, &amp;quot;&amp;quot;) -- trim white space&lt;br /&gt;
  if (message == &amp;quot;|reload&amp;quot;) then&lt;br /&gt;
    if (user == &amp;quot;ryan&amp;quot;) then&lt;br /&gt;
      dofile(&amp;quot;default.lua&amp;quot;)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  if (message == &amp;quot;|echo&amp;quot;) then&lt;br /&gt;
      SendIRC(user, &amp;quot;hello&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
  if (message:find(&amp;quot;|giflet&amp;quot;) ~= nil) then&lt;br /&gt;
      local figstr = message:sub(8)&lt;br /&gt;
      local sd = io.popen(&amp;quot;figlet &amp;quot; .. figstr)&lt;br /&gt;
      while(line) do&lt;br /&gt;
            SendIRC(user, line)&lt;br /&gt;
      end&lt;br /&gt;
      sd:close()&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Lua]]&lt;br /&gt;
[[Category:OpenWest 2014]]&lt;/div&gt;</summary>
		<author><name>Kenneth</name></author>
	</entry>
</feed>