Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 17 Apr 2006
Offline Last Active Jun 15 2014 02:19 PM

Topics I've Started

Registering strongly-typed class nested enums

23 May 2014 - 04:22 PM

I'm using AS 2.24.0. I have a class like this:


class foo
enum class state : int { a = 0, b, c };


I want to register that in AngelScript. I have registration code like this:


Engine->RegisterObjectType("foo", sizeof(foo), asOBJ_REF | asOBJ_NOCOUNT);
    Engine->RegisterEnumValue("foo::state", "stopped", static_cast<int>(foo::state::a));
    Engine->RegisterEnumValue("foo::state", "playing", static_cast<int>(foo::state::b));
    Engine->RegisterEnumValue("foo::state", "paused", static_cast<int>(foo::state::c));


However, I seem to be getting errors due to the following piece of AS code in asCScriptEngine::ResgisterEnum:


// Make sure the name is not a reserved keyword
size_t tokenLen;
int token = tok.GetToken(name, strlen(name), &tokenLen);
if( token != ttIdentifier || strlen(name) != tokenLen )
return ConfigError(asINVALID_NAME, "RegisterEnum", name, 0);


What am I doing wrong here?

Upgrading to SVN Trunk causes registration errors

28 November 2013 - 05:58 PM

I tried to upgrade my code to the SVN trunk version of AngelScript and my previously working code is now throwing errors during type registration. 



When I try to register the direction() member function of my ray() class using this call:


Engine->RegisterObjectMethod("ray", "float3 direction() const", asMETHODPR(ray, direction, (void) const, float3), asCALL_THISCALL);


I get this error message:


(0, 0) : ERR  : Failed in call to function 'RegisterObjectMethod' with 'ray' and 'float3 direction() const' (Code: -7)


Any idea what's going on here? The code was working fine with an earlier version of AngelScript.

Alignment requirements

27 November 2013 - 04:11 PM

I'm having trouble registering a float3 class with a float3(float x, float y, float z) constructor as a scoped ref type. Calls specifying asBEHAVE_CONSTRUCT fail when the flags are asOBJ_REF | asOBJ_SCOPED and adding asOBJ_APP_CLASS fails when registering the object type. How would I do that? 


If possible, I'd like to cast a vote for the alignment feature request described at http://www.gamedev.net/topic/606270-memory-aligned-objects/?gopid=4835684 - aligned vector types exist in every single game engine that I know of, and that option would significantly improve the ease of binding.

When to play impact sounds based on physics collisions?

24 November 2013 - 08:01 PM

I'm trying to set up a simple demo where physics-based dominoes tumble and fall. I have an audio clip that I want to play as the impact sound (that plastic-on-plastic sounds you get when dominoes hit each other) and I'm not sure about when to play it. I tried playing it on every collision being reported from Bullet physics engine (ignoring the play commend if the sound is currently playing, obviously) but that doesn't seem to be the way to do it. This might be obvious to someone who did that before but I'd like to hear what's usually done in this case.

Async compilation

23 November 2013 - 03:19 PM

Does AngelScript support async compilation of scripts? In other words, can I compile a script on a background thread while my main thread keeps updating UI, graphics etc.?