1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
/*
ClanLib and Lua Example
Created by:
Lenny Palozzi
domain@ica.net
Oct. 22, 1999.
*/
#include <ClanLib/core.h>
#include <ClanLib/lua.h>
#include <ClanLib/application.h>
#include <ClanLib/display.h>
#include <iostream>
using namespace std;
class LuaTestApp : public CL_ClanApplication
{
public:
virtual char *get_title() { return "Lua Script Example Application"; }
virtual int main(int argc, char **argv)
{
try
{
// Create a console window for text-output if not available
CL_ConsoleWindow console("Console");
console.redirect_stdio();
CL_SetupCore::init();
CL_SetupDisplay::init();
//CL_Display::set_videomode(640,480,16,false);
CL_Lua::init();
CL_Lua::strlibopen();
CL_Lua::mathlibopen();
//int result=CL_Lua::dofile("ex2.lua");
int result=CL_Lua::dofile("script.lua");
if (result)
{
}
cout << result << endl;
}
catch (CL_Error err)
{
std::cout << "Exception caught: " << err.message.c_str() << std::endl;
return -1;
}
catch (const string s)
{
std::cout << "Exception caught: " << s << std::endl;
return -1;
}
catch (const char *s)
{
std::cout << "Exception caught: " << s << std::endl;
return -1;
}
catch (...)
{
std::cout << "Unknown exception caught: " << std::endl;
}
CL_Lua::deinit();
CL_SetupDisplay::deinit();
CL_SetupCore::deinit();
return 0;
}
} app;
|