Seed is always stuff:random_int(), but "all caps", "maxlen" and "start" are specifiable, though default to false, -1, and 0 (as per make_name()).
As each parameter is a different type (bool, int and char), it would be good if the wrapper looked at type instead of parameter position, but this will do for now.
Signed-off-by: Robert Vollmert <rvollmert@gmx.net>
JTVUAALTZP6FW3D3QJUSOUGMEDNZB4F4HGUMYFHWGEJV2ETRBIBQC
std::string _crawl_make_name (lua_State *ls)
{
// A quick wrapper around itemname:make_name. Seed is random_int().
// Possible parameters: all caps, max length, char start. By default
// these are false, -1, and 0 as per make_name.
if (lua_gettop(ls) == 0)
return make_name (random_int(), false);
else
{
bool all_caps (false);
int maxlen = -1;
char start = 0;
if (lua_gettop(ls) >= 1 && lua_isboolean(ls, 1)) // Want all caps.
all_caps = lua_toboolean(ls, 1);
if (lua_gettop(ls) >= 2 && lua_isnumber(ls, 2)) // Specified a maxlen.
maxlen = lua_tonumber(ls, 2);
if (lua_gettop(ls) >= 3 && lua_isstring(ls, 3)) // Specificied a start character
start = lua_tostring(ls, 3)[0];
return make_name (random_int(), all_caps, maxlen, start);
}
}
LUARET1(crawl_make_name, string, _crawl_make_name(ls).c_str())