Alrighty, I'm looking at starting a simple project shortly, but it isn't a game. I easily get frustrated by things like batch files and their limited functionality, and I have never messed with the windows "powershell" that now exists. And on linux my knowledge is basic. However linux has a bonus over windows, in that Cron Jobs is super easy to use if you understand it, and so can automate your tasks.
What I am looking at writing, as a way to learn Lua, is a "luaexec" application that acts as a windows service and periodically executes various Lua scripts. For example if I wanted to clean my temp dir, and my delphi projects area of unneeded stuff I could have the script run once a week.
However I am wondering about a few things.
How would I execute a script, giving it information it may need as "configuration" that is dependent upon a per-script basis? For example, returning a table of named keys for the settings. IE:
Code:
settings = {
extensions = {
".dcu",
".log",
},
whitelist = {
"mydocs",
},
blacklist = {
"user_tempdir"
},
mainDir = "C:\Delphi",
}
I am guessing it would be better to create a threaded lua script that checks the given timeframe, and then executes a script given the 'settings' variable. So I guess you could say something like this would be effective.
Code:
luaExec = {
Tasks = {},
}
function luaExec:AddTask(script, settings, period)
tables.insert(luaExec.Tasks,{ func = script, options = settings, frequency = period, });
end
function luaExec:Init()
luaExec.AddTask();
end
function luaExec:Process()
end
luaExec.Init()
CreateThreadedProcess('luaExec', 'Process')
Starting to loose my though process in writing that... Anyhow. Bascially, is it better to have an XML configuration file with settings, scripts, and date/numerical periods to execute a script, or is there a way I could do it all in a sort of library fashion? Like put all the scripts into the library and then you just configure when you want them to run, and any settings they may need.
I'm confusing myself here. Gah. So I'll just start with the simple question: How do I pass a lua table from Delphi to a given lua script? Where it may contain a table or multiple tables within itself.
And, what is better in my case? Making a main lua script that handles most the gruntwork, or sort of splitting it between the two?
Bookmarks