Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Jake Albano

Member Since 10 Aug 2010
Offline Last Active Dec 14 2014 05:33 PM

Topics I've Started

"Behaviour already registered" - troubles after upgrading

20 March 2013 - 05:10 PM

I just upgraded to the latest release after skipping one or two releases -- back from when we were still using FuncIDs. I've got my code compiling, but it doesn't run any more; behavior checks for all of my classes are asserting.

 

Here's the output from my check functions (they check the return value and print messages copied from the AS documentation):

 

-- Error (line 0, column 0) : Failed in call to function 'RegisterObjectBehaviour' with 'Component' and 'Component@ f()' (Code: -13)
Failed registering behavior with type 'Component: The behaviour is already registered with the same signature
Assertion failed: r >= 0, file C:\Users\Jake\Documents\CodeBlocks\indigo\IndigoSDK\indigo\/scripting/asIClassBinder.h, line 151

 

I can post more info if necessary; I was just wondering if this was a known problem. I haven't changed anything in the binding process since upgrading.


Static / Type members?

30 January 2013 - 10:37 AM

I've recently gotten in the habit of using static member constants and the named constructor idiom to improve readability of my C++ code. For example:

 

Vector3 vec = Vector3::Up;
Matrix mat = Matrix::Identity;

if (getPosition() == Vector3::Zero)
{
}

 

I think the addition of constant class members to Angelscript would be really helpful. Something like this -- in C++:

class MyCType
{
    ...
    static const int MyConst;
};

...

engine->RegisterTypeProperty("MyType", "int myConst", &MyCType::myConst); // just like RegisterGlobalProperty

 

...and in Angelscript:

int foo = MyType.myConst; // properties accessed through the type, not an instance

 

Is there any chance we'll see a feature like this? I'd be willing to try and implement it myself, but I have no idea where to start.


Implicit cast to bool

17 October 2012 - 08:47 PM

What is the reasoning behind disallowing implicit value casts to bool? Is there a better way to do the same thing?

I'm looking to be able to do something like this:

Keystate@ state = keyboard.getKeystate("space");

// elsewhere...
if (state)
{
   // key is down
}

Template methods

08 August 2012 - 06:59 PM

I have a class which is responsible for creating instances of my component classes, registered as a singleton. Currently it looks like this:

[source lang = "cpp"]// IComponent is an abstract C++ class that all of my components extend in the applicationIComponent@ animation = componentFactory.get("SpriteAnimation");[/source]

Obviously this isn't ideal; for one thing, errors won't be caught until the line is executed. I'm wondering if there's any way for a method to take a template parameter, like this:

[source lang = "cpp"]IComponent@ animation = componentFactory.get<SpriteAnimation>(); // returns an instance of SpriteAnimation[/source]

All I can find in the docs is a way to register template types, which won't help me with this. Is there something I'm missing, or could this be added in a future release?

Thanks

Pointers to member functions

15 July 2012 - 07:16 PM

I can't seem to find any mention of whether this is possible or not. I'll explain what I'd like to do, and if it's impossible feel free to shoot me down. Posted Image

I have a keyboard class registered as a singleton in my game engine, so my scripts can access key state. The interface looks like this:

if (keyboard.space)
{
	doStuff();
}

The keys (in this case 'space') are implemented as property accessors that return a bool.

I'd like to be able to do something like this:

bind(@keyboard.space, @doStuff);

In this case, a pointer to the accessor would be stored along with a pointer to another function. The first function would be called continually, and if it returns true the second function would be called. I understand I could get the function object by declaration and set the calling object in the application, but I'd like to be able to do this with function and funcdefs.

So I'm wondering two things, actually:
  • Are pointers to member functions possible currently, or might they be in a future version?
  • If they are possible, would pointers to accessors need to be declared in long-form (@obj.get_prop), or would the short-form work as well (@obj.prop)?

PARTNERS