srunobantana
Member
- Joined
- Oct 24, 2021
- Messages
- 42
- Reaction score
- 19
I have the doSetHealthBackgroundOutfit function in TFS 0.4
File: luascript.cpp
In TFS 0.4, the doSetHealthBackgroundOutfit function is registered as follows:
luascript.CPP
luascript.H
Now I need the same function for TFS 1.3. Can anyone help?
I tried adapting the code for TFS 1.3, but I couldn't get it to work since the code structure is quite different. The interaction with Lua and the outfit-changing functions have undergone significant changes in version 1.3.
For this reason, I'm adding custom health bars that I used in TFS 0.4.



File: luascript.cpp
In TFS 0.4, the doSetHealthBackgroundOutfit function is registered as follows:
luascript.CPP
C++:
// Register the function in Lua
lua_register(m_luaState, "doSetHealthBackgroundOutfit", LuaInterface::luaDoSetHealthBackgroundOutfit);
int32_t LuaInterface::luaDoSetHealthBackgroundOutfit(lua_State* L)
{
// Arguments: doSetHealthBackgroundOutfit(cid, healthBackground)
ScriptEnviroment* env = getEnv();
uint16_t healthBg = popNumber(L); // Get the healthBackground value
const Creature* creature = env->getCreatureByUID(popNumber(L)); // Retrieve the creature by UID
if (!creature) {
errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); // If the creature is not found
lua_pushboolean(L, false); // Return "false" in case of error
return 1;
}
Outfit_t outfit = creature->getCurrentOutfit(); // Get the current outfit of the creature
outfit.healthBackground = healthBg; // Set the healthBackground in the outfit
g_game.internalCreatureChangeOutfit(const_cast<Creature*>(creature), outfit, true); // Apply the outfit change
lua_pushboolean(L, true); // Return "true" indicating success
return 1;
}
luascript.H
C++:
// Function declaration for Lua
static int32_t luaDoSetHealthBackgroundOutfit(lua_State* L);
Now I need the same function for TFS 1.3. Can anyone help?
I tried adapting the code for TFS 1.3, but I couldn't get it to work since the code structure is quite different. The interaction with Lua and the outfit-changing functions have undergone significant changes in version 1.3.
Post automatically merged:
For this reason, I'm adding custom health bars that I used in TFS 0.4.


