A Brief Introduction to Lua Scripting - The First Step to World of Warcraft's Interface Customization

Words
416
Reading
2 min
Listen
Play
9y

Lua (portuguese for "Moon") is the scripting language used for World of Warcraft's interface customization. It's light, fast, portable, embeddable and very easy to learn.

The most interesting thing about the Lua scripting languages is not that:

  • Lua is free to download, install and use
  • Lua is open source
  • Lua is small and fast
  • Lua is portable
  • Lua is embeddable
  • Tiobe reports that Lua is the 20th most used programming language with 0.557% of programmers using it
  • Lua is Portuguese for "Moon"

One reason for Lua's success is that it is used as part of the interface customization for World of Warcraft (WoW), and it's an interesting fact that:

As well as World of Warcraft, Lua is used in (to name but a few):

  • Adobe Photo Lightshop
  • Apache
  • Baldur's Gate
  • Damn Small Linux
  • Heroes of Might and Magic
  • MySQL
  • SciTE
  • Supreme Commander

So, obviously Lua must be very complicated to use? Well, no, it's not. And that is why Lua is so powerful – it can be used as easily in a small scale development in Windows as a complex application targeted for a Playstation or a GameCube.

Installing Lua

The Lua installation application can be downloaded directly from the http://www.lua.org Lua web site. It's worth noting that Lua requires the Microsoft Visual C++ SP1 redistributable to be installed as well (although the installation process will attempt to do that if the redistributable is missing and the user's computer is connected to the Internet).

image.png

A Simple Lua Script

Lua comes with its own command line interface, and so, once Lua has been installed the programmer can click the desktop shortcut to Lua, or start a command prompt and then type 'lua'. It's then just a matter of trying out some scripting (as can be seen in figure 1 at the bottom of this article):

print ('Hello World')

Once the obligatory 'Hello World' has been tried out then it can be turned into a function:

function hello ()
print ('Hello World')
end

Which can then be called by typing:

hello()

And, of course, the programmer will then want the function to accept inputs:

function hello (name)
print ('Hello ' .. name)
end

This is run by typing:

hello ('Me')

If this code is now saved to a file (for example c:\lua\hello) then it can run from any command prompt by typing:

lua c:\lua\hello

At this point the programmer can relax with a nice cup of Moca, look at WoW and say "I know how that all works". Well, maybe not, but at least they'll have taken their first steps down that road.



Posted on Utopian.io - Rewarding Open Source Contributors

A Brief Introduction to Lua Scripting - The First Step to World of ... | Ecency