Files
pip/main.cpp
2020-07-22 23:00:31 +03:00

33 lines
710 B
C++

#include "pip.h"
#ifdef PIP_LUA
#include "piluaprogram.h"
static const char * script
= "-- script.lua \n"
"test()\n"
"testString = \"LuaBridge works ававава!\" \n"
"number = 42 \n";
void test() {
piCout << "C function test";
}
int main() {
PILuaProgram p;
p.getGlobalNamespace().addFunction("test", test);
if (!p.load(PIString::fromUTF8(script))) piCout << "error";
p.prepare();
luabridge::LuaRef s = p.getGlobal("testString");
luabridge::LuaRef n = p.getGlobal("number");
PIString luaString = s.cast<PIString>();
int answer = n.cast<int>();
piCout << luaString;
piCout << "And here's our number:" << answer;
}
#else
int main() {
return 0;
}
#endif