diff options
Diffstat (limited to 'plugins/MirLua/src/m_schedule.cpp')
-rw-r--r-- | plugins/MirLua/src/m_schedule.cpp | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/plugins/MirLua/src/m_schedule.cpp b/plugins/MirLua/src/m_schedule.cpp index 05563c1cc8..e79d0932c1 100644 --- a/plugins/MirLua/src/m_schedule.cpp +++ b/plugins/MirLua/src/m_schedule.cpp @@ -464,7 +464,18 @@ static int lua__Do(lua_State *L) return 0;
}
-static const luaL_Reg schedule[] =
+static int lua__index(lua_State *L)
+{
+ int t1 = lua_type(L, 1);
+ int t2 = lua_type(L, 2);
+
+ //lua_pushvalue(L, 1);
+ lua_getmetatable(L, 1);
+
+ return 1;
+}
+
+static const luaL_Reg scheduleMeta[] =
{
{ "Second", lua__Second },
{ "Seconds", lua__Seconds },
@@ -487,11 +498,15 @@ static const luaL_Reg schedule[] = { "Until", lua__Until },
{ "Do", lua__Do },
+ //{ "__index", lua__index },
+
{ NULL, NULL }
};
/***********************************************/
+#define MT_SCHEDULETASK "SCHEDULETASK"
+
static int lua__At(lua_State *L)
{
time_t timestamp = time(NULL);
@@ -512,9 +527,21 @@ static int lua__Every(lua_State *L) {
int interval = luaL_optinteger(L, 1, 0);
- luaL_newlib(L, schedule);
+ int top = lua_gettop(L);
+ luaL_newlib(L, scheduleMeta);
+ //lua_newtable(L);
lua_pushinteger(L, interval);
lua_setfield(L, -2, "Interval");
+ top = lua_gettop(L);
+
+ lua_createtable(L, 0, 1);
+ //lua_pushcfunction(L, lua__index);
+ lua_pushvalue(L, -2);
+ lua_setfield(L, -2, "__index");
+ lua_setmetatable(L, -2);
+ top = lua_gettop(L);
+
+ //luaL_setmetatable(L, MT_SCHEDULETASK);
return 1;
}
@@ -532,6 +559,12 @@ LUAMOD_API int luaopen_m_schedule(lua_State *L) {
luaL_newlib(L, scheduleApi);
+ //luaL_newmetatable(L, MT_SCHEDULETASK);
+ /*lua_pushvalue(L, -1);
+ lua_setfield(L, -2, "__index");*/
+ //luaL_setfuncs(L, scheduleMeta, 0);
+ //lua_pop(L, 1);
+
if (hScheduleEvent == NULL)
hScheduleEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
|