lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Hakki Dogusan a écrit :

What about running a ngui script via lua.exe ?

I believe ngui as lua module would open new ways to use it.

Folowing is an example using wxLua. There is no message loop
there. All gui is handled in script. This program just starts it:

#include <windows.h>
extern "C"
    #include <lua.h>
    #include <lauxlib.h>
    #include <lualib.h>

//from lua.c
static int report (lua_State *L, int status) {
  if (status && !lua_isnil(L, -1)) {
    const char *msg = lua_tostring(L, -1);
    if (msg == NULL) msg = "(error object is not a string)";
    MessageBox(NULL, msg, NULL, 0); //l_message(progname, msg);
    lua_pop(L, 1);
  return status;

int WINAPI WinMain (HINSTANCE hThisInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR lpszArgument,
                     int nCmdShow)
    lua_State* L = lua_open();
    if (!L)
        MessageBox(NULL, "Could not open Lua", NULL, 0);
        return 0;
    luaL_openlibs(L);  // open std libraries
    int rc = luaL_loadfile(L, "./bbsc.lua") ||   // parse ok?
             lua_pcall(L, 0, LUA_MULTRET, 0);    // call main
    report(L, rc);
    return rc;

Hakki Dogusan

is it so different from test.cpp ?
But anyway I think that having a message loop somewhere in ngui is a good idea.
Thank you for your excellent suggestions
Best wishes

Noël Frankinet
Gistek Software SA