[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lua source as config file
- From: George Petsagourakis <petsagouris@...>
- Date: Thu, 8 Feb 2007 10:57:18 +0000 (UTC)
Luiz Henrique de Figueiredo <lhf <at> tecgraf.puc-rio.br> writes:
>
> > but the return makes it look less like a config file.
>
> Drop the return and the table constructor all together and use a custom
> dofile, one that adds "return {" at the beginning and "}" at the end.
> This will allow (and restrict) config files to be a series assignments.
> On the other hand, you'll need commas or semicolons after each assignments;
> semicolons seem better in this case.
> --lhf
>
>
Maybe something like this then ?
function getconfig( file )
local f,e = io.open( file )
if e then
return error( "No configuration! "..file.." not found!")
end
local ret = "return {"
for line in f:lines() do
ret = ret.."\r\n"..line..","
end
return ret.."\r\n}"
end