From c6ae568ed88f465fce4656164e1bd35d163e75aa Mon Sep 17 00:00:00 2001 From: fgenesis Date: Sun, 21 Jul 2013 04:28:45 +0200 Subject: [PATCH] More Lua functions; allow specifying ingredient type by ID - avatar_setBlockBackflip() - avatar_isBlockBackflip() - inv_getNumItems() - inv_getItemName() - getIngredientDataSize() - getIngredientDataName() --- Aquaria/Avatar.cpp | 3 +++ Aquaria/Avatar.h | 2 ++ Aquaria/Continuity.cpp | 12 +++++++++++ Aquaria/DSQ.h | 4 ++++ Aquaria/ScriptInterface.cpp | 41 +++++++++++++++++++++++++++++++++++++ 5 files changed, 62 insertions(+) diff --git a/Aquaria/Avatar.cpp b/Aquaria/Avatar.cpp index edf18ae..50e7f19 100644 --- a/Aquaria/Avatar.cpp +++ b/Aquaria/Avatar.cpp @@ -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; diff --git a/Aquaria/Avatar.h b/Aquaria/Avatar.h index 0287a1d..3bb6afa 100644 --- a/Aquaria/Avatar.h +++ b/Aquaria/Avatar.h @@ -346,6 +346,8 @@ public: int leaches; float shieldPoints; + + bool blockBackFlip; protected: void setSongIconPositions(); diff --git a/Aquaria/Continuity.cpp b/Aquaria/Continuity.cpp index 18ae971..6928803 100644 --- a/Aquaria/Continuity.cpp +++ b/Aquaria/Continuity.cpp @@ -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; diff --git a/Aquaria/DSQ.h b/Aquaria/DSQ.h index 523ff86..0360ca3 100644 --- a/Aquaria/DSQ.h +++ b/Aquaria/DSQ.h @@ -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 sortByType, sortByHeal, sortByIngredients, sortByUnsort; StatsAndAchievements *statsAndAchievements; + protected: std::vector eats; std::vector speedTypes; diff --git a/Aquaria/ScriptInterface.cpp b/Aquaria/ScriptInterface.cpp index 25eae88..ddbbd5b 100644 --- a/Aquaria/ScriptInterface.cpp +++ b/Aquaria/ScriptInterface.cpp @@ -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),