Advertisement

Internal value of bool?

Started by October 04, 2013 02:51 PM
1 comment, last by zexee 11 years, 1 month ago

I am just met trouble of use c++ to access bool value in angelscript. There is no SetArgBool or GetReturnBool, and it said bool is 8bit in the document. So I used *(bool*)GetAddressOfReturnValue() but it turned out wrong.

I looked at the memory, it seemed that true is 0 and false is 255 in byte. If so, that is different from c++ tradition (as far as I can remember, in c++ 0 is false and all others are true), and it should be documented or provide set and get function.

bool in AngelScript uses the same binary value as in C++. 0 for false and 1 for true (though anything different than 0 will be interpreted as true).

*(bool*)GetAddressOfReturnValue() should work, as should GetReturnByte().

What does the script function look like? And did the Execute() method return asEXECUTION_FINISHED? If it didn't return with this value the script function didn't return yet (or an exception was raised) and obviously any return value you try to get will not be what you expect.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement

Sorry, it was my mistake. I was actually calling opCmp so equal is 0. Thank you for your answering!

This topic is closed to new replies.

Advertisement