BRL.MaxLua
BlitzMax Forums/BlitzMax Programming/BRL.MaxLua
| ||
Hi, How can I return True or False from a BlitzMax type method to Lua? Example: Type MyType Method isTrue(a) If a = whatever Return True Else Return False EndIf EndMethod EndType I use LuaRegisterObject. My Lua code doesn't seem to recognise the result returned. Thanks for any help! |
| ||
Can we see your Lua script? Edit: Anyhow, I'm sure when I see the script you'll be checking for true/false, which are booleans and not numbers. Numbers and booleans in Lua are not exactly the same, so you're not going to be able to test for them. You'll have to test for 1 or 0, or modify the invoker to check for some sort of metadata to specify when it should treat the result of a method as a boolean value. While I'm at it, consider looking at my LuaRef code in my bmax-misc Github repo. MaxLua is pretty flawed, so I figure what I wrote is a bit closer to a good alternative. |
| ||
Return an integer. From the Pil: Lua considers both zero and the empty string as true in conditional tests So return -1 for false, and anything else for true. |
| ||
So return -1 for false, and anything else for true. That's not going to work if you're testing the returned number against a boolean. Run 'print(-1==false)' through an interpreter. Different data types are never equal. |
| ||
Nilium's implementation is so much better than MaxLua. Use it! |