Lua/Tutorial

Welcome to the Scribunto-Lua Tutorial. Want to see a specific template adapted to Lua in our Demo at the Berlin Hackathon 2012? Then please add it (with link) to this list, below.

How to Use this Tutorial
This tutorial was originally developed for the 2012 Berlin Hackathon, a face-to-face event. It has been adapted for on-wiki, remote use, as you see it here. As all things wiki, it is a living document and we encourage you to participate in developing and maintaining it.

The content below, is focused on established MediaWiki template developers. Everyone is welcome to use it. If you're new to templates on MediaWiki, but have Lua experience, you may want to find out more about templates. Note that some things in Scribunto, do not apply to the Lua distro. If you're a MediaWiki template guru, but new to Lua, you will learn some cool, new magic. If you're new to both, you will find that the MediaWiki community has many people willing to help you learn.

Introduction to Lua
WikiText does not parse the way you would normally expect. Parser frames are arguments in Scribunto templates. Strip markers replace certain markup, which if it is passed, will result in placeholders instead of markup. You will need to use the new Namespace:Module
 * Lua scripting general information and brief historical context of its planned use in MediaWiki.
 * Status of Lua scripting on MediaWiki
 * What is Lua? Check out the Lua.org demo if you don't want to DL Scributno just yet.
 * Lua evolution PDF and |Lua version history
 * What is different from JS and OO languages we could have used?
 * Scribunto: How is the Lua implementation in MediaWiki different?


 * How you adapt for these differences

Suggested Templates You Want to See Adapted During the Demo
Please post the link to a template that you'd like to see adapted to Lua as a demo, on-stage during the tutorial.
 * 1) (first template suggestion)

Setting up for Lua scripting in MediaWiki
How to set up your environment and other preparation. Scribunto download

Setting up for Lua (what you need, resources, etc)
Scribunto works out-of-the-box, without having to set up a Lua environment. It includes the Lua binary for both Linux and Windows, 32 bit and 64 bit OSes. For better performance, there is also a Scribunto sandbox that has been tested on OSX.

If you plan to use the extension binary from MediaWiki, download Scribunto from Gerrit, to your extensions directory.

If you really want to build Lua on your system, these are the instructions from Lua.org. Building Lua

Lua Implementation Plan as Part of MediaWiki Roadmap

 * Extension:WikiScripts
 * Return value expansion, access to the frame object and bug fixing

Scribunto Extension
A new namespace called, "Module," is a collection of call-able functions in wikitext syntax.

External Resources for general/non-wiki Lua Scripting

 * Lua 5.1 Reference Manual
 * Programming in Lua

Tutorial Feedback
If you saw this tutorial live, in Berlin, please give us your feedback on the Talk page, so we can refine it for future hackathons and other events. You can give anonymous feedback if you prefer.