What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

Lua.GetReturnVal<bool> doesn't work?

Inrego

New Member
Joined
Feb 7, 2010
Messages
2,765
Reaction score
71
I couldn't figure out why it always returned false, then I tried this:
Code:
Log("" + Lua.GetReturnVal<bool>("return true", 0));
which writes false to the output log. Am I totally off here or what?
 
why you are putting a return value into a string which returns a bool.
 
It was just for printing the value in HBConsole so I can see the value.
 
Well nvm, I changed my lua code to return 0 or 1 instead, and then I grab these values.
 
Well nvm, I changed my lua code to return 0 or 1 instead, and then I grab these values.

Our Lua handler doesn't really support "true/false" returns for bools. (I don't believe there was any API that returned so when we wrote it) In most cases, we'll just return a string, or int, and compare the value. (Lua supports far too many ways to return "true" or "false" for us to handle them all. Its safer to just return a string in most cases, and do a string comparison.)

I realize we should be doing better about it, but its just due to Lua being an odd scripting language really.

False: 0, nil, false, <empty>, -1, <multiple other values>
True: 1, true, <anything not in false>
 
Our Lua handler doesn't really support "true/false" returns for bools. (I don't believe there was any API that returned so when we wrote it) In most cases, we'll just return a string, or int, and compare the value. (Lua supports far too many ways to return "true" or "false" for us to handle them all. Its safer to just return a string in most cases, and do a string comparison.)

I realize we should be doing better about it, but its just due to Lua being an odd scripting language really.

False: 0, nil, false, <empty>, -1, <multiple other values>
True: 1, true, <anything not in false>
Thanks for the explanation. As I said before I changed my lua scripts to return 0 and 1 instead of true/false so I worked it out that way (as you can also see in my shared lua scripts here on dev forum)
 
Back
Top