void Lua_V2::GetActorChores() {
	lua_Object actorObj = lua_getparam(1);
	if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R'))
		return;
	Actor *actor = getactor(actorObj);
	Costume *costume = actor->getCurrentCostume();

	lua_Object result = lua_createtable();
	lua_pushobject(result);

	if (!costume) {
		lua_pushstring("count");
		lua_pushnumber(0);
		lua_settable();
		lua_pushobject(result);
		return;
	}

	int num = costume->getNumChores();

	lua_pushstring("count");
	lua_pushnumber(num);
	lua_settable();

	for (int i = 0; i < num; ++i) {
		lua_pushobject(result);
		lua_pushnumber(i);
		lua_pushusertag(((EMIChore *)costume->getChore(i))->getId(), MKTAG('C','H','O','R'));
		lua_settable();
	}

	lua_pushobject(result);
}
void Lua_V2::IsActorChoring() {
	lua_Object actorObj = lua_getparam(1);
	bool excludeLoop = getbool(2);

	if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != MKTAG('A','C','T','R'))
		return;

	Actor *actor = getactor(actorObj);
	Costume *costume = actor->getCurrentCostume();

	if (!costume) {
		lua_pushnil();
		return;
	}

	for (int i = 0; i < costume->getNumChores(); i++) {
		int chore = costume->isChoring(i, excludeLoop);
		if (chore != -1) {
			// Ignore talk chores.
			bool isTalk = false;
			for (int j = 0; j < 10; j++) {
				if (costume == actor->getTalkCostume(j) && actor->getTalkChore(j) == chore) {
					isTalk = true;
					break;
				}
			}
			if (isTalk)
				continue;

			lua_pushnumber(chore);
			
			pushbool(true);
			return;
		}
	}

	lua_pushnil();
}