diff options
author | Alex Auvolat <alex@adnab.me> | 2017-04-21 18:26:22 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2017-04-21 18:26:22 +0200 |
commit | ed153e6a5b9f001bbe49128e6bc53053f55dd37b (patch) | |
tree | 9a9bbe3551ea1b5de71aa3c358fd13f46c603191 /src/sysbin/lx/lxlib.c | |
parent | f8334e283c5eb0efeb4bb8a134041e18388d5f01 (diff) | |
download | kogata-ed153e6a5b9f001bbe49128e6bc53053f55dd37b.tar.gz kogata-ed153e6a5b9f001bbe49128e6bc53053f55dd37b.zip |
Can plot on a surface from lua
Diffstat (limited to 'src/sysbin/lx/lxlib.c')
-rw-r--r-- | src/sysbin/lx/lxlib.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/sysbin/lx/lxlib.c b/src/sysbin/lx/lxlib.c index 9f6843b..ed266f7 100644 --- a/src/sysbin/lx/lxlib.c +++ b/src/sysbin/lx/lxlib.c @@ -29,6 +29,13 @@ bool lx_checkboolean(lua_State *L, int arg) { return lua_toboolean(L, arg); } +void* lx_checklightudata(lua_State *L, int arg) { + if (!lua_islightuserdata(L, arg)) { + luaL_argerror(L, arg, "expected light userdata"); + } + return lua_touserdata(L, arg); +} + void setintfield (lua_State *L, const char *key, int value) { lua_pushinteger(L, value); @@ -39,3 +46,10 @@ void setstrfield (lua_State *L, const char *key, const char* value) { lua_pushstring(L, value); lua_setfield(L, -2, key); } + +int getintfield(lua_State *L, int arg, const char *key) { + lua_getfield(L, arg, key); + int v = luaL_checkinteger(L, -1); + lua_pop(L, 1); + return v; +} |