Lua


Lua Logo

Lua is a lightweight programming language.  It was originally designed to be embedded into programs to provide a scripting and configuration system. It is now also frequently used as a standalone programming language.

From the authors on www.lua.org:
A fundamental concept in the design of Lua is to provide meta-mechanisms for implementing features, instead of providing a host of features directly in the language. For example, although Lua is not a pure object-oriented language, it does provide meta-mechanisms for implementing classes and inheritance. Lua's meta-mechanisms bring an economy of concepts and keep the language small, while allowing the semantics to be extended in unconventional ways. Extensible semantics is a distinguishing feature of Lua.

It is really quite refreshing to have a language that is flexible enough to extend itself into numerous different roles without becoming bloated and overcomplex. It also manages to be extremely readable to non-professionals (since this was one of the design goals as an embedded scripting language). Of course also being one of the fastest scripting languages (overall) doesn't hurt.

Anyway I have written a couple of bits and bats which I will include here, as I get them into a "condition" where I feel they are useful.

Description
file
A Dice library - a nice simple example of why scripting languages are far more productive for many tasks than more 'conventional' languages. Try repeating the semantics of DiceFunction(str) in C/C++ (No cheating I will want to read the dice equations from a configuration file at runtime)

Note 3d8 (for example) means the sum of 3 throws of a 8 sided dice in classic D&D style.

This kind of thing is useful for games (gambling, roguelike, strategy etc.)
dice.lua (requires lua 5.0)
HTML Preprocessor (this site uses it extensively) Very simple, but suprisingly powerful for just less than 150 lines. It really could do with better error handling since syntax problems lead to rather cryptic messages, or just plain stupid output.

It uses exension tags <$tag morestuff> to work it's magic (see source for more examples) including:
   <$insert "filename">
   <$set var stuff>
   <$var>
   <$datetime "format">

It is easy enough to add your own tags (if you understand regular expressions [regexes])

I will produce a manual at some point.
htmpp.lua version 0.1 (requires lua 5.0)
htmpp_example.zip

Note all files are distributed under a BSD like license described in the source files (licenses are a very political area, and I personally prefer it to the alternatives - all flames cheerfully redirected to /dev/null)

Copyright © 2002-2005 Ian King, All Rights Reserved.
If anything doesn't work properly in your browser please let me know!
Site authored using gvim and htmpp v0.1
Page Last Modified: 12:21 AM Fri 5 May 2006