Lua

From PZwiki
Revision as of 01:27, 23 November 2012 by Pianoman (talk | contribs)


What is Lua?

Lua is a powerful, fast, surprisingly lovely and simple scripting language. It is easily embedded into Java code (which Project Zomboid is written in) and thus was an ideal choice for the Indie Stone to introduce to the modding community. Lua appeared from the 0.2.0 test versions onwards, resulting in some fantastic mods. Some of these have gone on to be implemented as part of the vanilla game (Stormy's Reloading Mod, RobertJohnson's Farming Mod and Camping Mod).


How do I write and edit Lua code?

In order to create code, you will first need a program to write in. You could do this in Notepad, but this would make it significantly more difficult than it needs to be. We recommend you choose one of the programs listed below. There is a variety of programs, all of which have advantages:


This is popular amongst many coders. You can download a Lua language file which highlights Lua keywords and helps make code more readable.


This program highlights Lua keywords and datatypes for easy reading. Most importantly it also contacts a Lua IDE, meaning that you can run Lua code inside the program. For this reason, this is the best tool for when you are learning Lua.


This is an excellent tool that highlights syntax errors and suspicious globals. It was recommended by lemmy101 and makes a great tool for making actual mods.


Learning Lua

Due to it's simplicity, Lua is a language easily picked up by both programmers and non-programmers alike. These early tutorials are written with the assumption the reader has no previous knowledge of programming, i.e. the absolute beginner. For those with experience who might get impatient with the pace of these tutorials, we recommended reading 'Programming in Lua', with the first edition available for free.

The tutorials here are intended to be done in order, so that the techniques and complexity of examples increase as you become for comfortable with the language. They first introduce you to the Lua language (with PZ in mind), before moving on to specifically using Lua for Project Zomboid. Like any skill, it will take time and practice to learn, so don't be put off if you don't master something immediately.


Extra Learning Resources

You might also want to have a look at the Lua video tutorials on this channel: https://www.youtube.com/user/DevHQLessons

There are also addition tutorials available here: http://lua-users.org/wiki/LuaTutorial