Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Desdemona

AngelScript + bools

This topic is 5177 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!