From eae5fcb3ba5701255083cc6745a76c4e618d443c Mon Sep 17 00:00:00 2001 From: Dan Guzek Date: Mon, 1 Sep 2014 19:00:00 -0400 Subject: [PATCH] expose InsertCoin and InsertCredit to Lua This commit exposes InsertCoin() and InsertCredit() to Lua under GAMESTATE. It adds a check to ensure overall credits don't become negative when deducting and only plays sounds if credits are being added. Themers are instructed to deduct credits by passing negative values to InsertCoin. --- Docs/Luadoc/Lua.xml | 2 + Docs/Luadoc/LuaDocumentation.xml | 7 +++ src/GameState.cpp | 38 +++++++++----- src/StepMania.cpp | 88 +++++++++++++++++--------------- 4 files changed, 82 insertions(+), 53 deletions(-) diff --git a/Docs/Luadoc/Lua.xml b/Docs/Luadoc/Lua.xml index 3e9d5c4669..cca7e62894 100644 --- a/Docs/Luadoc/Lua.xml +++ b/Docs/Luadoc/Lua.xml @@ -810,6 +810,8 @@ + + diff --git a/Docs/Luadoc/LuaDocumentation.xml b/Docs/Luadoc/LuaDocumentation.xml index b0ad156762..4dbeb7bbc1 100644 --- a/Docs/Luadoc/LuaDocumentation.xml +++ b/Docs/Luadoc/LuaDocumentation.xml @@ -2478,6 +2478,13 @@ save yourself some time, copy this for undocumented things: editing portion. If in recording or playing mode, this will return false. + + Inserts iCoins number of coins. iCoins can be negative or positive. + + + Inserts one credit. To deduct a credit, pass a negative integer representing the number + of coins per credit to InsertCoin. + Returns true if this is an extra stage. diff --git a/src/GameState.cpp b/src/GameState.cpp index fd2c05eb0d..a316a2e3e0 100644 --- a/src/GameState.cpp +++ b/src/GameState.cpp @@ -32,6 +32,7 @@ #include "SongManager.h" #include "SongUtil.h" #include "StatsManager.h" +#include "StepMania.h" #include "Steps.h" #include "Style.h" #include "ThemeManager.h" @@ -396,7 +397,7 @@ void GameState::JoinPlayer( PlayerNumber pn ) // dance-threepanel, popn-nine). -aj // XXX?: still shows joined player as "Insert Card". May not be an issue? -aj if( m_pCurStyle->m_StyleType == StyleType_OnePlayerTwoSides || - m_pCurStyle->m_StepsType == StepsType_dance_solo || + m_pCurStyle->m_StepsType == StepsType_dance_solo || m_pCurStyle->m_StepsType == StepsType_dance_threepanel || m_pCurStyle->m_StepsType == StepsType_popn_nine ) pStyle = GAMEMAN->GetFirstCompatibleStyle( m_pCurGame, 1, m_pCurStyle->m_StepsType ); @@ -2221,7 +2222,7 @@ MultiPlayer GetNextEnabledMultiPlayer( MultiPlayer mp ) #include "LuaBinding.h" #include "Game.h" -/** @brief Allow Lua to have access to the GameState. */ +/** @brief Allow Lua to have access to the GameState. */ class LunaGameState: public Luna { public: @@ -2531,7 +2532,7 @@ public: vEP.push_back( pn ); LuaHelpers::CreateTableFromArray( vEP, L ); return 1; - } + } static int GetCurrentStyle( T* p, lua_State *L ) { Style *pStyle = const_cast