diff options
| author | jacob1 <jfu614@gmail.com> | 2012-08-21 23:08:20 (GMT) |
|---|---|---|
| committer | jacksonmj <mj-pt@jacksonmj.co.uk> | 2012-09-02 20:59:28 (GMT) |
| commit | 2932b04e0e123bb06e958bd6b7f3d2767afdff0b (patch) | |
| tree | d0a3d1e3acc7290cc84c41332ebb2c3262c1b893 /src | |
| parent | 40d9f48b722caeb87b574fc9f136a46363d326e3 (diff) | |
| download | powder-2932b04e0e123bb06e958bd6b7f3d2767afdff0b.zip powder-2932b04e0e123bb06e958bd6b7f3d2767afdff0b.tar.gz | |
tpt.element also converts numbers to names
Diffstat (limited to 'src')
| -rw-r--r-- | src/luaconsole.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/luaconsole.c b/src/luaconsole.c index 02b8514..ba63127 100644 --- a/src/luaconsole.c +++ b/src/luaconsole.c @@ -887,10 +887,19 @@ int luatpt_test(lua_State* l) int luatpt_getelement(lua_State *l) { int t; - char * name = luaL_optstring(l, 1, "dust"); - if (!console_parse_type(name, &t, NULL)) - return luaL_error(l,"Unrecognised element '%s'", name); - lua_pushinteger(l, t); + char* name; + if(lua_isnumber(l, 1)){ + t = luaL_optint(l, 1, 1); + if (t<0 || t>=PT_NUM) + return luaL_error(l, "Unrecognised element number '%d'", t); + name = ptypes[t&0xFF].name; + lua_pushstring(l, name); + } else { + name = (char*)luaL_optstring(l, 1, "dust"); + if (!console_parse_type(name, &t, NULL)) + return luaL_error(l, "Unrecognised element '%s'", name); + lua_pushinteger(l, t); + } return 1; } int luatpt_element_func(lua_State *l) |
