Jump to content

  • Log In with Google      Sign In   
  • Create Account

- - - - -

AngelScript + bools


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Desdemona   Members   -  Reputation: 158

Like
Likes
Like

Posted 22 March 2004 - 12:51 PM

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]

Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3334

Like
Likes
Like

Posted 22 March 2004 - 01:30 PM

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

#3 Andreas Jonsson   Moderators   -  Reputation: 3334

Like
Likes
Like

Posted 23 March 2004 - 02:45 AM

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS