Tomasu / LuaGlue

C++11 Lua 5.2 Binding Library
zlib License
79 stars 22 forks source link

add helpers to determine if globals (or table fields) are specific types #73

Open ehrhart opened 10 years ago

ehrhart commented 10 years ago

I'd like to know if it's possible to check if a global function exists before doing invokeFunction or invokeVoidFunction.

If I try to call a function that doesn't exist, the stack keeps getting filled with "`attempt to call a nil value'" Any ideas on how to prevent this?

Thanks

Tomasu commented 10 years ago

Well, the invoke methods really should be poping the errors back off the lua stack. but I could add a globalExists or similar method.

Tomasu commented 10 years ago

Now it wont fill the stack with junk, but you can also now check if a global exists via globalExists, it does not check its type, rather that the global is not nil. I may think about adding a couple helpers that check if its a function or table, etc, as well.

ehrhart commented 10 years ago

Thanks a lot, works like a charm. Some helpers would be useful for sure, but globalExists helps a lot already