1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-11-15 14:09:06 +00:00

More Lua functions; allow specifying ingredient type by ID

- avatar_setBlockBackflip()
- avatar_isBlockBackflip()
- inv_getNumItems()
- inv_getItemName()
- getIngredientDataSize()
- getIngredientDataName()
This commit is contained in:
fgenesis 2013-07-21 04:28:45 +02:00
parent 08821f5156
commit c6ae568ed8
5 changed files with 62 additions and 0 deletions

View file

@ -4129,6 +4129,8 @@ Avatar::Avatar() : Entity(), ActionMapper()
_collisionAvoidRange = COLLIDE_RANGE_NORMAL;
_seeMapMode = SEE_MAP_DEFAULT;
blockBackFlip = false;
}
void Avatar::revert()
@ -4282,6 +4284,7 @@ void Avatar::startBackFlip()
{
if (boneLock.on) return;
if (riding) return;
if (blockBackFlip) return;
skeletalSprite.getAnimationLayer(ANIMLAYER_OVERRIDE)->transitionAnimate("backflip", 0.2, 0);
vel.x = -vel.x*0.25f;

View file

@ -346,6 +346,8 @@ public:
int leaches;
float shieldPoints;
bool blockBackFlip;
protected:
void setSongIconPositions();

View file

@ -165,6 +165,8 @@ IngredientType Continuity::getIngredientTypeFromName(const std::string &name) co
return IT_MUSHROOM;
else if (name == "Anything")
return IT_ANYTHING;
else if (name.length() && isdigit(name[0]))
return (IngredientType)atoi(name.c_str());
return IT_NONE;
}
@ -190,6 +192,16 @@ IngredientData *Continuity::getIngredientDataByIndex(int idx)
return ingredientData[idx];
}
int Continuity::getIngredientDataSize() const
{
return (int)ingredientData.size();
}
int Continuity::getIngredientHeldSize() const
{
return (int)ingredients.size();
}
Recipe::Recipe()
{
known = false;

View file

@ -1067,6 +1067,9 @@ public:
IngredientData *getIngredientHeldByIndex(int idx) const;
IngredientData *getIngredientDataByIndex(int idx);
int getIngredientDataSize() const;
int getIngredientHeldSize() const;
bool applyIngredientEffects(IngredientData *data);
void loadIngredientData();
@ -1152,6 +1155,7 @@ public:
std::vector<FoodSortOrder> sortByType, sortByHeal, sortByIngredients, sortByUnsort;
StatsAndAchievements *statsAndAchievements;
protected:
std::vector<EatData> eats;
std::vector<int> speedTypes;

View file

@ -2998,6 +2998,18 @@ luaFunc(avatar_isBlockSinging)
luaReturnBool(dsq->game->avatar->isBlockSinging());
}
luaFunc(avatar_setBlockBackflip)
{
dsq->game->avatar->blockBackFlip = getBool(L);
luaReturnNil();
}
luaFunc(avatar_isBlockBackflip)
{
dsq->game->avatar->blockBackFlip = getBool(L);
luaReturnNil();
}
luaFunc(avatar_fallOffWall)
{
dsq->game->avatar->fallOffWall();
@ -8083,6 +8095,29 @@ luaFunc(inv_pickupEffect)
luaReturnNil();
}
luaFunc(inv_getNumItems)
{
luaReturnInt(dsq->continuity.getIngredientHeldSize());
}
luaFunc(inv_getItemName)
{
IngredientData *data = dsq->continuity.getIngredientHeldByIndex(lua_tointeger(L, 1));
luaReturnStr(data ? data->name.c_str() : "");
}
luaFunc(getIngredientDataSize)
{
luaReturnInt(dsq->continuity.getIngredientDataSize());
}
luaFunc(getIngredientDataName)
{
IngredientData *data = dsq->continuity.getIngredientDataByIndex(lua_tointeger(L, 1));
luaReturnStr(data ? data->name.c_str() : "");
}
luaFunc(learnRecipe)
{
std::string name = getString(L, 1);
@ -8774,6 +8809,8 @@ static const struct {
luaRegister(avatar_fallOffWall),
luaRegister(avatar_setBlockSinging),
luaRegister(avatar_isBlockSinging),
luaRegister(avatar_setBlockBackflip),
luaRegister(avatar_isBlockBackflip),
luaRegister(avatar_setSpeedMult),
luaRegister(avatar_setSpeedMult2),
@ -9112,7 +9149,11 @@ static const struct {
luaRegister(inv_getType),
luaRegister(inv_getDisplayName),
luaRegister(inv_pickupEffect),
luaRegister(inv_getNumItems),
luaRegister(inv_getItemName),
luaRegister(learnRecipe),
luaRegister(getIngredientDataSize),
luaRegister(getIngredientDataName),
luaRegister(createDebugText),
luaRegister(createBitmapText),