Page 1 of 1
Persistent global Lua state
Posted: Mon Jan 03, 2005 6:07 am
by Michael
Hi Jussi,
would be cool to have access to some persistent global Lua state/table/registry across script/macro calls so it would be easy to implement some more advanced macros relying on some former actions/acting incrementally.
Best regards,
Michael
Posted: Mon Jan 03, 2005 2:32 pm
by jussij
Hi Michael,
This might be a little difficult to achive since for all the Zeus scripting languages the scripting engine is recreated each time. In other words a new instance of the interpreter is created each time a script is run
But Zeus does offer a very limited amount of global persistence, via the following scripting functions:
Code: Select all
string get_global_string(string item [, int local_scope])
bool set_global_string(string item, string value [, int local_scope])
For more information about these functions place the cursor on each function in turn and use the
Help, Quick Help menu option.
Cheers Jussi
Posted: Mon Jan 03, 2005 3:37 pm
by Guest
Hi Jussi,
I've found some script code in the archive pages of your website - is that code the one used in current builds and does Zeus load the DLL on each scriptexec or just initialize the scripting state using an already loaded DLL? If so I may be able to build a modified version for my special needs.
Best regards,
Michael
Posted: Tue Jan 04, 2005 1:37 am
by jussij
Hi Michael,
I have update the web page to include the latest source code for the Zeus Lua Scripting module code. To build the scriptlua.dll just download the zip file and follow instructions in the readme.txt file.
does Zeus load the DLL on each scriptexec or just initialize the scripting state using an already loaded DLL?
Below is the code that Zeus uses to run the the script using the dll. I have never checked but I suspect the dll is loaded and unloaded each time a script is run.
Code: Select all
{
//-- this class wraps aroung the scripting dll
iModule module(szDllName);
//-- run the execute
sResult = msvc_execute(module, pInterface, pszScript);
}
int msvc_execute(iModule &module, xInterface *pInterface, const char *pszScript)
{
int sResult = 0;
//-- get the module proc address
FARPROC farproc = module.proc("execute");
if (farproc)
{
__try
{
//-- get the execute entry point
MACRO_EXECUTE pfnExecute = (MACRO_EXECUTE)farproc;
//-- run the entry point
sResult = (*pfnExecute)(pszScript, pInterface);
}
__except(ExceptionFilter())
{
::MessageBox(0, pszFatal, "Scripting Error", MB_OK | MB_ICONEXCLAMATION);
}
}
return sResult;
}
If so I may be able to build a modified version for my special needs.
All the files required to build the dll should be included in the zip file, but if you have any problems building the dll let me know. If you have any questions feel free to post them here or alternatively you can also send me an e-mail.
Cheers Jussi
Posted: Tue Jan 04, 2005 4:54 am
by Michael
Wow, that's what I call great and fast support.
Thanks a lot, even if I've used the global strings for a first workaround for the bookmarks script I will definately have a look at the updated sources and see what I can do with it for later needs.