Guizek69
New Member
- Joined
- Jul 14, 2020
- Messages
- 10
- Reaction score
- 3
Hello Otlanders!
I would like to use this TFS 1.2 function in my TFS 0.4 for fun.
Could anyone help me convert this code?
I would like to use this TFS 1.2 function in my TFS 0.4 for fun.
Could anyone help me convert this code?
int LuaScriptInterface::luaPlayerGetContainerById(lua_State* L)
{
// player:getContainerById(id)
Player* player = getUserdata<Player>(L, 1);
if (!player) {
lua_pushnil(L);
return 1;
}
Container* container = player->getContainerByID(getNumber<uint8_t>(L, 2));
if (container) {
pushUserdata<Container>(L, container);
setMetatable(L, -1, "Container");
} else {
lua_pushnil(L);
}
return 1;
}
Container* Player::getContainerByID(uint8_t cid)
{
auto it = openContainers.find(cid);
if (it == openContainers.end()) {
return nullptr;
}
return it->second.container;
}