Luther's Lua Pack (1.8) / Lua Globals (1.9.4)

Discussion of Lua and LuaWML support, development, and ideas.

Moderators: Forum Moderators, Developers

Luther's Lua Pack (1.8) / Lua Globals (1.9.4)

Postby Luther » January 22nd, 2011, 7:41 am

I have a file, called 'globals.lua', that I've been using to contain all the boilerplate that I believe should go at the top of every Wesnoth Lua file. From reading this forum, it seems there are a lot of new Lua coders who are starting themselves off by making content for Wesnoth 1.9. I think my file could make things a lot easier, so I decided to upgrade it to 1.9 and announce it here. It's been available for 1.8 since September, but I didn't announce it until now. 'globals.lua' contains no fancy tricks (except for the 1.8 implementation of W, which holds the action tags). It merely takes advantage of the stuff that the Wesnoth platform provides to make our lives easier. If you're starting out with Lua, I suggest you download the add-on, read the README, then read 'globals.lua' to see how it's done.

If you have Wesnoth 1.8, download Luther's Lua Pack, and put this at the top of your Lua file:
Code: Select all

If you have Wesnoth 1.9, download Lua Globals and put this at the top of your Lua file:
Code: Select all

Here are the tables that it provides:

H: Name for the table returned by lua/helper.lua.

T: Creates subtags for use within WML tables. The index is the name of the tag to create. This gives a function whose argument is the WML within the tag.
This Lua table:
Code: Select all
  x = 84,
  y = 42,
  radius = 1,
    terrain = 'K*,C*'

... is equivalent to this WML:
Code: Select all

V: Interface for reading and writing WML variables.

W: Alias for wesnoth.wml_actions. (In Luther's Lua Pack, this is implemented by hand.)

Luther's Lua Pack also has some other files that contain some new tags. I had started to convert the mainline macros to tags, which I talk about in this thread, but I think I misjudged the usefulness of that project. In practice, I usually just write a new custom tag for every event that I write. I will fix bugs that anyone finds up until 1.10beta comes out, but I don't plan to upgrade this stuff.

Lua Globals also includes location_set, which is the table returned by lua/location_set.lua.

Hope this helps, and thanks to all the devs that made this stuff possible...
Posts: 114
Joined: July 28th, 2007, 5:19 pm
Location: USA

Return to Lua Labs

Who is online

Users browsing this forum: No registered users and 2 guests