aboutsummaryrefslogtreecommitdiffstats
path: root/src/base
diff options
context:
space:
mode:
authorHawkear <Hawkear@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-01-03 02:21:14 +0000
committerHawkear <Hawkear@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-01-03 02:21:14 +0000
commitdee46c9e1faf98750496e04352b5b3411b979d2f (patch)
treee96fb1e18553fa468b49a91ea99c8c18a3d5a581 /src/base
parent2ec120340f57d3e5d23643828a44418d75ca8fd1 (diff)
downloadusdx-dee46c9e1faf98750496e04352b5b3411b979d2f.tar.gz
usdx-dee46c9e1faf98750496e04352b5b3411b979d2f.tar.xz
usdx-dee46c9e1faf98750496e04352b5b3411b979d2f.zip
Functions from ULog and some from OpenGL available in Lua
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/Lua@1548 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'src/base')
-rw-r--r--src/base/UMain.pas29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/base/UMain.pas b/src/base/UMain.pas
index 6300f18b..99127b76 100644
--- a/src/base/UMain.pas
+++ b/src/base/UMain.pas
@@ -46,6 +46,7 @@ uses
ULyrics,
UScreenSing,
USong,
+ ULua,
gl;
type
@@ -116,6 +117,7 @@ var
PlayersPlay: integer;
CurrentSong : TSong;
+ Lua : Plua_State;
const
MAX_SONG_SCORE = 10000; // max. achievable points per song
@@ -180,6 +182,8 @@ uses
UGraphicClasses,
UPluginDefs,
UPlatform,
+ ULuaLog,
+ ULuaGl,
UThemes;
@@ -379,6 +383,19 @@ begin
Log.LogBenchmark('Initializing Joystick', 1);
end;
+ // Lua
+ Log.BenchmarkStart(1);
+ Lua := luaL_newstate;
+ if Lua = nil then
+ Log.LogError('Lua init failed','Lua');
+ luaL_openlibs(Lua);
+
+ luaopen_Log(Lua); // Log + Benchmark (Lua)
+ luaopen_gl(Lua); // gl (Lua)
+
+ Log.BenchmarkEnd(1);
+ Log.LogBenchmark('Initializing Lua', 1);
+
Log.BenchmarkEnd(0);
Log.LogBenchmark('Loading Time', 0);
@@ -416,6 +433,8 @@ begin
//TTF_Quit();
SDL_Quit();
+ lua_close(Lua);
+
if assigned(Log) then
begin
Log.LogStatus('Main Loop', 'Finished');
@@ -446,6 +465,16 @@ begin
// display
done := not Display.Draw;
+
+ // FIXME remove this when the Partymode works
+ if FileExists('main.lua') then
+ begin
+ if 0 <> luaL_dofile(Lua, 'main.lua') then
+ begin
+ Log.LogError(lua_tostring(Lua,-1));
+ end;
+ end;
+
SwapBuffers;
// delay