Archive for the 'Lua' category

PawnDoc 0.1 released

Today I finished PawnDoc 0.1. You may download PawnDoc at the official PawnDoc wiki page.

The tool PawnDoc is a tool for the Pawn language similar to JavaDoc for Java. With pawndoc-comments in your pawn sourcecode you can generate documentation-html-files and even wiki-syntax! See dprop.inc.wiki.txt or dprop.inc.html as example (source .pwn).

You can also find a welcome post at samp forums. PawnDoc is written in Lua 5.1.

DModule 0.13 finished

Today I got the first update of DModule for you guys. DModule 0.13 contains again some cool new features, like enchanced pawn-doc reader and a completely new command line interface to dmodule project managment! Very handy if you want to check what modules your project chooses from which directory or if you want to add modules on the fly.

Also it contains a bugfixed version of GetPlayerTeam and SetPlayerTeam (and the Spawn-Functions) to fix the issues with friendly fire in SA-MP.

Here is the detailed list of changes, also available in the Changelog:

  • Added bugfixed version of SetPlayerTeam, GetPlayerTeam, SetSpawnInfo and AddPlayerClass(Ex) to provide working friendly fire in samp.
  • Added commandline interface for project management
  • Updated the pwn-doc reader
    • able to read @param type varname description
    • reading params_def correctly
    • removing &’s and & from param name
  • Ships now with
    • dini 1.5.2
    • dcmd
    • timestamp
    • dplayers 1.1
    • dsystem 1.0
    • dutils 1.11
    • inouticon 1.0
    • inoutmsg 1.0
    • killlist 1.0
    • killpunish 1.0
    • killreward 1.0
    • loginout 1.0
    • modeconfig 1.0
    • teamspawn 1.1

Fast in_array or in_list implemented Lua?

On lua mailing list somebody asked if there is any way to check very short if an element is in a specific list of elements.

In php you would do for example if (in_array("A",array("A","B","C")) ) { echo "hello"; }

Of course, everyone can write a short in_table function in Continue reading

Convert Title-String to Url Slug in PHP or Lua

When making your urls looking better, you may want to convert a title to a url-slug.

An url-slug is in common a string containing only alphanumeric letters and ‘-’. Following php and lua function converts it to that format.

php:

function toSlug($str) {
return str_replace(" ","-",ereg_replace("[ ]+"," ",ereg_replace("[^ A-Za-z0-9]","",$str)));
}

lua:
function toSlug(str)
return string.gsub(string.gsub(str,"[^ A-Za-z]",""),"[ ]+","-")
end

The toSlug function also replaces multiple spaces with one ‘-‘ only.

You can find this Lua-How-To at luanet.net, too.

Base-Dir-Restriction for LUA

Today I finished at LuaNET a how to about a restricting lua script access to its own directory. Also known as BaseDir restriction.

To use this you’ll need to have LuaFileSystem installed

Lua table introduction

Today I finished the small introduction in lua’s powerful table element. Even though it shows most of the intuitive design of tables in lua, its good if you also have a look at the pages of the other table-functions like table.concat, to get detailed examples.

LuaNET launched!

Today I finished first part of LuaNET. Its not yet finished, but has already lots of functions (which will be in, when its finished).

LuaNET is intended to give users documentation for lua api, Lua How-Tos and of course a Lua Support Forum (which have been missing in the lua world).

This page is still in beta, please try it and leave some comments!

#1 Introduction to programming

Today I finally finished the first part of my “Einführung in die Programmierung“.

Currently its a german article about Programming in general explained with Lua.

It includes introduction in commands (functions) and propertys (attribute), but also an introduction in using them.

Finished first version of luainfo()

Since its available for php as phpinfo I made a luainfo.lua for lua, too.

It shows loaded packages, response vars and other server variables.

Grab a preview in this rendered html file and grab the MIT-licensed luainfo.lua source.

Fixed issue in mod_wombat

Yesterday I talked with BrianM, author of mod_wombat, about issues compiling the current svn version with gcc 4.1.

With revision 528215 in the svn.apache.org he applied my patch. Thanks for the credits.