Skip to content

Commit

Permalink
Utility function that I didn't end up using but which could be useful…
Browse files Browse the repository at this point in the history
… elsewhere
  • Loading branch information
CelticMinstrel committed Feb 11, 2018
1 parent 0c9bc4b commit cbd72e9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/scripting/lua_common.cpp
Expand Up @@ -595,6 +595,17 @@ t_string luaW_checktstring(lua_State *L, int index)
return result;
}

bool luaW_isstring(lua_State* L, int index)
{
if(lua_isstring(L, index)) {
return true;
}
if(lua_isuserdata(L, index) && luaL_testudata(L, index, tstringKey)) {
return true;
}
return false;
}

void luaW_filltable(lua_State *L, const config& cfg)
{
if (!lua_checkstack(L, LUA_MINSTACK))
Expand Down
6 changes: 6 additions & 0 deletions src/scripting/lua_common.hpp
Expand Up @@ -78,6 +78,12 @@ bool luaW_totstring(lua_State *L, int index, t_string &str);
*/
t_string luaW_checktstring(lua_State *L, int index);

/*
* Test if a scalar is either a plain or translatable string.
* Also returns true if it's a number since that's convertible to string.
*/
bool luaW_isstring(lua_State* L, int index);

/**
* Converts a config object to a Lua table.
* The destination table should be at the top of the stack on entry. It is
Expand Down

0 comments on commit cbd72e9

Please sign in to comment.