Skip to content

Commit

Permalink
give lua access to scoregoal elements
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed Apr 28, 2017
1 parent 67b18f2 commit cff3868
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions src/Profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3799,14 +3799,36 @@ LUA_REGISTER_CLASS( Profile )
class LunaScoreGoal : public Luna<ScoreGoal>
{
public:
static int GetRate(T* p, lua_State *L) {
lua_pushnumber(L, p->rate);
DEFINE_METHOD(GetRate, rate);
DEFINE_METHOD(GetPercent, percent);
DEFINE_METHOD(GetPriority, priority);
DEFINE_METHOD(IsAchieved, achieved);
DEFINE_METHOD(GetComment, comment);
DEFINE_METHOD(WhenAssigned, timeassigned.GetString());

static int WhenAchieved(T* p, lua_State *L) {
if (p->achieved)
lua_pushstring(L, p->timeachieved.GetString());
else
lua_pushnil(L);

return 1;
}

static int SetRate(T* p, lua_State *L) { p->rate = FArg(1); return 1; }
static int SetPercent(T* p, lua_State *L) { p->percent = FArg(1); return 1; }
static int SetPriority(T* p, lua_State *L) { p->priority = IArg(1); return 1; }
static int SetComment(T* p, lua_State *L) { p->comment = SArg(1); return 1; }

LunaScoreGoal()
{
ADD_METHOD( GetRate );
ADD_METHOD(GetRate);
ADD_METHOD(GetPercent);
ADD_METHOD(GetPriority);
ADD_METHOD(IsAchieved);
ADD_METHOD(GetComment);
ADD_METHOD(WhenAssigned);
ADD_METHOD(WhenAchieved);
}
};
LUA_REGISTER_CLASS(ScoreGoal)
Expand Down

0 comments on commit cff3868

Please sign in to comment.