I just looked in the RTL document and you're 100% right. Silly me. :roll:

I do that so often I sometimes want to beat my head against the table. Anyhow.

I can't really give a full blown example at the moment because I haven't written anything; I need a function that finds all scripts in the library directory and gives that to my main script. So there's one of two methods: passing back a table, or calling a handler function. I'm not entirely certain how to do either. What I would do is register a global variable, we'll just call it library, with a sub-table named scripts.

IE:
Code:
 -- Main.lua

library = {
  scripts = {},
}
So I would do something like register this function (forgive me, I'm really crawling in the dark on how to make a table in Lua) with Lua:[pascal]procedure system_search(L : PLua_State);
var
searchResult : TSearchRec;
mask: string;
results: longint;
begin
mask := lua_tostring(L,1);
if FindFirst(mask, faAnyFile, searchResult) = 0 then
begin
repeat
// lua_pushstring(L,searchResult.Name); ?
inc(results);
until FindNext(searchResult) <> 0;

// Must free up resources used by these successful finds
FindClose(searchResult);
end;
lua_settable(L,-results); // ?
end;[/pascal]

Then I'd call it in the script sort of like this:
Code:
library.scripts = system.find&#40;"library/*.lua"&#41;
And it would return something about like this:
Code:
&#123;
  "hello.lua",
  "recursive_search.lua",
&#125;
And so on.

Like I said, I'm really lost on how to mess with functions and passing back and forth parameters and results. Not to mention just how to go about designing a function like that, since I've never worked with a stack before.