Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ehrhart opened this issue Sep 6, 2014 · 3 comments
Open

Comments

@ehrhart
Copy link
Contributor

ehrhart commented Sep 6, 2014

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
Copy link
Owner

Tomasu commented Sep 6, 2014

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 added a commit that referenced this issue Sep 6, 2014
…ors off the stack in invoke*Function methods in LuaGlue class. ref #73
@Tomasu
Copy link
Owner

Tomasu commented Sep 6, 2014

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
Copy link
Contributor Author

ehrhart commented Sep 6, 2014

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

@Tomasu Tomasu changed the title Check if global function exists before invoking it add helpers to determine if globals (or table fields) are specific types Sep 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants