Skip to content

Commit

Permalink
Added Lua bindings for new step length function
Browse files Browse the repository at this point in the history
  • Loading branch information
bluebandit21 committed Jul 8, 2020
1 parent 368ea70 commit 2eb8005
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 2 additions & 4 deletions Themes/_fallback/Scripts/10 WifeSundries.lua
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,8 @@ function formLink(x, y)
end

function GetPlayableTime()
local td = GAMESTATE:GetCurrentSteps(PLAYER_1):GetTimingData()
local song = GAMESTATE:GetCurrentSong()
return (td:GetElapsedTimeFromBeat(song:GetLastBeat()) - td:GetElapsedTimeFromBeat(song:GetFirstBeat())) /
getCurRateValue()
local step = GAMESTATE:GetCurrentSteps(PLAYER_1)
return step:GetLengthSeconds()
end

function ChangeMusicRate(rate, params)
Expand Down
7 changes: 7 additions & 0 deletions src/Etterna/Models/StepsAndStyles/Steps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,12 @@ class LunaSteps : public Luna<Steps>
LuaHelpers::CreateTableFromArray(p->Getdebugstrings(), L);
return 1;
}
static auto GetLengthSeconds(T* p, lua_State* L) -> int
{
float curr_rate = GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate;
lua_pushnumber(L, p->GetLengthSeconds(curr_rate));
return 1;
}
LunaSteps()
{
ADD_METHOD(GetAuthorCredit);
Expand Down Expand Up @@ -1130,6 +1136,7 @@ class LunaSteps : public Luna<Steps>
ADD_METHOD(GetNonEmptyNoteData);
ADD_METHOD(GetCalcDebugOutput);
ADD_METHOD(GetDebugStrings);
ADD_METHOD(GetLengthSeconds);
}
};

Expand Down

0 comments on commit 2eb8005

Please sign in to comment.