AngelScript + bools

Started by
1 comment, last by Desdemona 20 years ago
I'm having a problem with bools in v1.6.1... If I use global properties, they work as expected. The folllowing prints out 'false true false true'

   // In the program

   m_pEngine->RegisterGlobalProperty("bool g_bMyBool", &g_bMyBool, 0);

   // In the script

   g_bMyBool = false;

   if (g_bMyBool)  Console.Write("true\n");
   else            Console.Write("false\n");
      
   g_bMyBool = true;   

   if (g_bMyBool)  Console.Write("true\n");
   else            Console.Write("false\n");
      
   g_bMyBool = false;   

   if (g_bMyBool)  Console.Write("true\n");
   else            Console.Write("false\n");
      
   g_bMyBool = true;   

   if (g_bMyBool)  Console.Write("true\n");
   else            Console.Write("false\n");
But if I try and use a bool as an object property, things dont work quite right.

   Scripting.GetEngine().RegisterObjectType("CSPhysics", 0, 0);
   Scripting.GetEngine().RegisterGlobalProperty("CSPhysics Physics", this, 0);
   Scripting.GetEngine().RegisterObjectProperty("CSPhysics", "bool Enable", offsetof(CSPhysics, m_bEnable), 0);
If I did the same test as before, AngelScript will always read the bool 'Physics.Enable' as 'true'. I can assign values to 'Physics.Enable' and those values are applied correctly, but it is only read as true. D [edited by - Desdemona on March 22, 2004 9:47:58 PM] [edited by - Desdemona on March 22, 2004 9:48:32 PM]
Advertisement
The latest version 1.6.1 fixes a bug with the boolean type where AngelScript was using 4 bytes, when it should have been only 1. It could be that this is a part of that bug that was missed. I''ll do some more extensive testing with the boolean type to see if I can identify anymore bugs.

Oh, and about the boolean operators in AngelScript that you are having trouble with. They are as follows:

AS  : C++and : &&or  : ||not : ! 


Thus in angelscript you would write:

bool var = false;
if( not var )
{
do something...
}

Regards,
Andreas

__________________________________________________________
www.AngelCode.com - game development and more...
AngelScript - free scripting library

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

OK, I found and fixed the problem. Please download the new version 1.6.1a.

Thanks for telling me about the bug.

__________________________________________________________
www.AngelCode.com - game development and more...
AngelScript - free scripting library

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

This topic is closed to new replies.

Advertisement