I have been trying to make a function in C++ for a gameserver DLL which aligns given text to center before returning the new string to Lua for processing. I have spent quite
I'm going to assume you already know how to pass a string from Lua to C++ and return the result from C++ to Lua, so the only part we need to deal with is producing the centered string.
That, however, is pretty easy:
std::string center(std::string input, int width = 113) {
return std::string((width - input.length()) / 2, ' ') + input;
}