Homeslice
-anoyn/Rage the Mage
I couldn't find an easy way to get an item's full description using Lua. For example:
You see knight legs (Arm:8).
It can only be wielded properly by knights and paladins.
It weighs 70.00 oz.
In my case i added this functionality to see item stats in a Lua crafting system.
This requires source changes to do, so you will need to compile your own TFS exe.
In luascript.cpp Change:
To:
Above:
Add the following:
In luascript.h
Change:
To:
Now in your Lua scripts you can use: ItemType:getFullDescription()
You see knight legs (Arm:8).
It can only be wielded properly by knights and paladins.
It weighs 70.00 oz.
In my case i added this functionality to see item stats in a Lua crafting system.
This requires source changes to do, so you will need to compile your own TFS exe.
In luascript.cpp Change:
C++:
registerMethod("ItemType", "getDescription", LuaScriptInterface::luaItemTypeGetDescription);
C++:
registerMethod("ItemType", "getDescription", LuaScriptInterface::luaItemTypeGetDescription);
registerMethod("ItemType", "getFullDescription", LuaScriptInterface::luaItemTypeGetFullDescription);
Above:
C++:
int LuaScriptInterface::luaItemTypeGetDescription(lua_State* L)
C++:
int LuaScriptInterface::luaItemTypeGetFullDescription(lua_State* L)
{
// itemType:getFullDescription()
const ItemType* itemType = getUserdata<const ItemType>(L, 1);
if (itemType) {
pushString(L, Item::getDescription(*itemType, 1, nullptr, -1, false));
}
else {
lua_pushnil(L);
}
return 1;
}
In luascript.h
Change:
C++:
static int luaItemTypeGetDescription(lua_State* L);
C++:
static int luaItemTypeGetDescription(lua_State* L);
static int luaItemTypeGetFullDescription(lua_State* L);
Now in your Lua scripts you can use: ItemType:getFullDescription()