From 48b4b813a51c374fce43a553608c67c6ca08ea37 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Sun, 12 Jun 2011 21:51:47 +0200 Subject: Added a say() function to lua. --- scripting/test.cpp | 7 +++++++ scripting/test.h | 1 + scripting/test.pkg | 1 + 3 files changed, 9 insertions(+) (limited to 'scripting') diff --git a/scripting/test.cpp b/scripting/test.cpp index 1a378b7..5ec27da 100644 --- a/scripting/test.cpp +++ b/scripting/test.cpp @@ -9,3 +9,10 @@ void print(lua_State *L, const char *s) { lua_pop(L, 1); lua->print(s); } + +void say(lua_State *L, const char *s) { + lua_getglobal(L, "lua_instance"); + Lua *lua = static_cast(lua_touserdata(L, -1)); + lua_pop(L, 1); + lua->say(s); +} diff --git a/scripting/test.h b/scripting/test.h index 48f560e..7ff5719 100644 --- a/scripting/test.h +++ b/scripting/test.h @@ -4,5 +4,6 @@ #include void print(lua_State *L, const char *s); +void say(lua_State *L, const char *s); #endif diff --git a/scripting/test.pkg b/scripting/test.pkg index 38525c6..0f64be7 100644 --- a/scripting/test.pkg +++ b/scripting/test.pkg @@ -1,5 +1,6 @@ $hfile "scripting/test.h" void print(lua_State *L, const char *s); +void say(lua_State *L, const char *s); // vim: syn=cpp -- cgit v1.2.3