Skip to content

Commit

Permalink
add lua access to inputdata from replays
Browse files Browse the repository at this point in the history
  • Loading branch information
poco0317 committed Oct 29, 2022
1 parent 3e6fe84 commit 3c55e4c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
33 changes: 31 additions & 2 deletions src/Etterna/Models/HighScore/Replay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2196,6 +2196,12 @@ class LunaReplay : public Luna<Replay>
return 1;
}

static auto GetInputData(T* p, lua_State* L) -> int
{
LuaHelpers::CreateTableFromArray(p->GetInputDataVector(), L);
return 1;
}

DEFINE_METHOD(HasReplayData, HasReplayData())
DEFINE_METHOD(GetChartKey, GetChartKey())
DEFINE_METHOD(GetScoreKey, GetScoreKey())
Expand All @@ -2213,10 +2219,10 @@ class LunaReplay : public Luna<Replay>
ADD_METHOD(GetTapNoteTypeVector);
ADD_METHOD(GetHoldNoteVector);
ADD_METHOD(GetMineHitVector);
ADD_METHOD(GetInputData);
ADD_METHOD(GetReplaySnapshotForNoterow);
}
};

LUA_REGISTER_CLASS(Replay)

class LunaReplaySnapshot : public Luna<ReplaySnapshot>
Expand Down Expand Up @@ -2269,5 +2275,28 @@ class LunaReplaySnapshot : public Luna<ReplaySnapshot>
ADD_METHOD(GetWifePercent);
}
};

LUA_REGISTER_CLASS(ReplaySnapshot)

class LunaInputDataEvent : public Luna<InputDataEvent>
{
public:

DEFINE_METHOD(IsPress, is_press);
DEFINE_METHOD(GetColumn, column);
DEFINE_METHOD(GetSongPositionSeconds, songPositionSeconds);
DEFINE_METHOD(GetNearestTapNoterow, nearestTapNoterow);
DEFINE_METHOD(GetOffsetFromNearest, offsetFromNearest);
DEFINE_METHOD(GetNearestTapNoteType, nearestTapNoteType);
DEFINE_METHOD(GetNearestTapNoteSubType, nearestTapNoteSubType);

LunaInputDataEvent() {
ADD_METHOD(IsPress);
ADD_METHOD(GetColumn);
ADD_METHOD(GetSongPositionSeconds);
ADD_METHOD(GetNearestTapNoterow);
ADD_METHOD(GetOffsetFromNearest);
ADD_METHOD(GetNearestTapNoteType);
ADD_METHOD(GetNearestTapNoteSubType);
}
};
LUA_REGISTER_CLASS(InputDataEvent)
3 changes: 3 additions & 0 deletions src/Etterna/Models/HighScore/ReplayConstantsAndTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ struct InputDataEvent
nearestTapNoteType = other.nearestTapNoteType;
nearestTapNoteSubType = other.nearestTapNoteSubType;
}

/// Lua
void PushSelf(lua_State* L);
};

struct MineReplayResult
Expand Down

0 comments on commit 3c55e4c

Please sign in to comment.