28 lines
677 B
C++
28 lines
677 B
C++
#include "pip.h"
|
|
extern "C" {
|
|
# include "lua.h"
|
|
# include "lauxlib.h"
|
|
# include "lualib.h"
|
|
}
|
|
#include <LuaBridge/LuaBridge.h>
|
|
#include "pistring_std.h"
|
|
|
|
static const char * script
|
|
= "-- script.lua \n"
|
|
"testString = \"LuaBridge works!\" \n"
|
|
"number = 42 \n";
|
|
|
|
using namespace luabridge;
|
|
int main() {
|
|
lua_State* L = luaL_newstate();
|
|
luaL_dostring(L, script);
|
|
luaL_openlibs(L);
|
|
lua_pcall(L, 0, 0, 0);
|
|
LuaRef s = getGlobal(L, "testString");
|
|
LuaRef n = getGlobal(L, "number");
|
|
std::string luaString = s.cast<std::string>();
|
|
int answer = n.cast<int>();
|
|
piCout << StdString2PIString(luaString);
|
|
piCout << "And here's our number:" << answer;
|
|
}
|