Persistent global Lua state

Post any comments, suggestions, annoyances or ideas for future releases here. Please do not post bug reports or questions here.
Post Reply
Michael

Persistent global Lua state

Post 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
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post 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
Guest

Post 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
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post 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
Michael

Post 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.
Post Reply