From 14e96597c65a2402ee4ddc068ff08c7659123a1d Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Mon, 4 May 2009 07:29:52 +0000 Subject: old lua test stuff by hawkear removed or commented new function: Party.SetWinner sets winner of current round new unit ULuaUtils w/ some functions that are or may become useful moved Lua_ClearStack and Lua_ToBinInt to ULuaUtils added first hooks (have a look at hooks.txt in game/plugins until documentation is finished) lua module for TextGl written and finished lua testfile (game/scripts/main.lua) ported to new interface, see game/plugins/LuaTest.usdx git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/experimental@1709 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Lua/src/base/UMain.pas | 20 +++++++++++--------- Lua/src/base/UParty.pas | 23 +++++++++++++++++++++-- 2 files changed, 32 insertions(+), 11 deletions(-) (limited to 'Lua/src/base') diff --git a/Lua/src/base/UMain.pas b/Lua/src/base/UMain.pas index 57ad01a1..a1c77900 100644 --- a/Lua/src/base/UMain.pas +++ b/Lua/src/base/UMain.pas @@ -118,7 +118,7 @@ var PlayersPlay: integer; CurrentSong : TSong; - Lua : Plua_State; + //Lua : Plua_State; const MAX_SONG_SCORE = 10000; // max. achievable points per song @@ -228,6 +228,9 @@ begin SDL_Init(SDL_INIT_VIDEO or SDL_INIT_TIMER); SDL_EnableUnicode(1); + // create luacore first so other classes can register their events + LuaCore := TLuaCore.Create; + USTime := TTime.Create; VideoBGTimer := TRelativeTimer.Create; @@ -390,7 +393,7 @@ begin end; // Lua - Log.BenchmarkStart(1); + {Log.BenchmarkStart(1); Lua := luaL_newstate; if Lua = nil then Log.LogError('Lua init failed','Lua'); @@ -403,7 +406,7 @@ begin luaopen_TextGL(Lua); // TextGL (Lua) lua_pop(Lua, 1); // remove table from stack luaopen_Texture(Lua); // Texture (Lua) - lua_pop(Lua, 1); // remove table from stack + lua_pop(Lua, 1); // remove table from stack } Log.BenchmarkEnd(1); Log.LogBenchmark('Initializing Lua', 1); @@ -422,13 +425,12 @@ begin Party := TPartyGame.Create; - LuaCore := TLuaCore.Create; - LuaCore.RegisterModule('Log', ULuaLog_Lib_f); LuaCore.RegisterModule('Gl', ULuaGl_Lib_f); + LuaCore.RegisterModule('TextGl', ULuaTextGl_Lib_f); LuaCore.RegisterModule('Party', ULuaParty_Lib_f); - LuaCore.BrowseDir(PluginPath); + LuaCore.LoadPlugins; LuaCore.DumpPlugins; @@ -454,7 +456,7 @@ begin //TTF_Quit(); SDL_Quit(); - lua_close(Lua); + //lua_close(Lua); if assigned(Log) then begin @@ -487,14 +489,14 @@ begin // display done := not Display.Draw; - // FIXME remove this when the Partymode works + {// FIXME remove this when the Partymode works if FileExists(ScriptPath + 'main.lua') then begin if 0 <> luaL_dofile(Lua, PAnsiChar(ScriptPath + 'main.lua')) then begin Log.LogError(lua_tostring(Lua,-1)); end; - end; + end; } SwapBuffers; diff --git a/Lua/src/base/UParty.pas b/Lua/src/base/UParty.pas index 0be7cf61..1566e4e8 100644 --- a/Lua/src/base/UParty.pas +++ b/Lua/src/base/UParty.pas @@ -153,6 +153,10 @@ type function StartGame(Rounds: ARounds): Boolean; + { sets the winner(s) of current round + returns true on success } + function SetWinner(WinBin: Integer): Boolean; + { increases round counter by 1 and clears all round specific information; returns the number of the current round or -1 if last round has already been played } @@ -531,6 +535,18 @@ begin end; end; +{ sets the winner(s) of current round + returns true on success } +function TPartyGame.SetWinner(WinBin: Integer): Boolean; +begin + if (bPartyStarted) and (CurRound >= 0) and (CurRound <= High(Rounds)) then + begin + Rounds[CurRound].Winner := WinBin; + end + else + Result := false; +end; + { increases round counter by 1 and clears all round specific information; returns the number of the current round or -1 if last round has already been played } @@ -674,8 +690,11 @@ begin if (CallLua(Parent, Functions.AfterSing)) then begin // execute default function: - // display party score screen - Display.FadeTo(@ScreenPartyScore); + if (bPartyGame) then + // display party score screen + Display.FadeTo(@ScreenPartyScore) + else //display standard score screen + Display.FadeTo(@ScreenScore); end; end; end; -- cgit v1.2.3