AddOn Development in Rift (Lua), Day 1

So I decided to take a look at Rift-AddOn development. Before we get started, it is best to check out some of the popular lua-sites out there [15]. To make things easier, we’re going to build a very simple addon from scratch. I recommend using Eclipse for development and install Lua Development Tools from the Marketplace. 


Let’s begin!

Create a new lua project and call it main.lua. Additionally, create a .toc-file and name it RiftAddon.toc.

In the RiftAddon.toc, following fields are required:

  • Identifier
  • Name
  • Description
  • Author
  • Version
  • Email
  • Environment
  • RunOnStartup

For more information, see: http://wiki.riftui.com/RiftAddon.toc.

In my file, I added the following information:

In your main.lua, copy and paste the following code:

And that’s it! This is your first Rift-Addon!

To make things a little more interesting, Rift has implemented several functions that we can make use of. Additionally, there is this thing called events. Events allow us to register a function that will be called upon each rendered frame (from the game engine). A more in-depth explanation can be found here and here.

An Event (in respect to Rift addon development) can be anything from an incomming chat message, to a mouse-click on a button. The Rift API allows us to register our own functions to be called when such events occur. This is called event-handling.

 
The RiftUI Wiki has a listing of the events supported by Rift together with some basic documentation on some of these events. The API is still in its early stages and more events will be made available as it matures.[/perfectpullquote]
A full listing can be found here: http://www.seebs.net/rift/live/index.html
 
To make things a little more interesting, let’s test this out!
Edit your main.lua and add the following code:
 

Ok, so we’ve done three things here: 

  1. Create a function that prints out the text “Hi :D”
  2. Registered a new Slash-Event-Handler, called say (which is the function we created in 1.)
  3. Registered a new Slash-Alias, namely “/fiia” (each time you type this in the Rift chat, it will print out “Hi :D”

 

Now save your files, reload the addon in Rift (simply type “/reloadui” in Rift chat) and test it out! :DDD

 

We haven’t yet talked about what exactly we can do with functions and how they work, as well as what that dubious local FFA, data = ... means, but I’ll get to that on Day 2 of my adventures in Lua. 😀


Resources

[1] http://www.lua.org/pil/contents.html

[2] http://tylerneylon.com/a/learn-lua/

[3] http://lua-users.org/wiki/ObjectOrientedProgramming

[4] https://coronalabs.com/learn-lua/

[5] http://lua-users.org/wiki/ObjectOrientationTutorial