Why does asIObjectType not store their typeid?
As the title says, it seems like it's be nice not to have to create an object to get it's type id. I want to just be able to pull the object type and get it from that.
I can't answer the why, but you don't need to create an object to get the type ID. You can use asIScriptEngine::GetTypeIdByDecl() or asIScriptModule::GetTypeIdByDecl() to get a type ID from the type name.
hhhmm... problem is, I'm pulling these classes from a script by the interface they implement, so I don't know what their declaration looks like.
The only reason is that nobody asked for it before :)
However, until I update the interface you should follow SiCrane's advice. You only need the name of the type, i.e.
module->GetTypeIdByDecl("MyClass");
However, until I update the interface you should follow SiCrane's advice. You only need the name of the type, i.e.
module->GetTypeIdByDecl("MyClass");
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
If you already have the asIObjectType * but not the name, then you can use asIObjectType::GetName().
Ah crap, so my class inherits from an interface, so it looks like this:
So just passing "A" to:
GetTypeIdByDecl()
does not turn it up, instead I need to pass:
"A : B"
A few suggestions, any or all of them would be nice additions to make things like this smoother:
1) Store typeId in asIObjectType
2) Allow type look up by name rather than decl (might not possible?)
3) Provide a "getDecl" method in addition to the "getName" method
Quote:
class A : B {
}
So just passing "A" to:
GetTypeIdByDecl()
does not turn it up, instead I need to pass:
"A : B"
A few suggestions, any or all of them would be nice additions to make things like this smoother:
1) Store typeId in asIObjectType
2) Allow type look up by name rather than decl (might not possible?)
3) Provide a "getDecl" method in addition to the "getName" method
"A : B" shouldn't be necessary, in fact it would be an invalid declaration. Seems like you've hit another bug. I'll need to verify this.
You should know that the classes declared in the scripts are only visible to the GetTypeIdByDecl in the module. GetTypeIdByDecl in the engine will only return type ids for the application registered types.
You should know that the classes declared in the scripts are only visible to the GetTypeIdByDecl in the module. GetTypeIdByDecl in the engine will only return type ids for the application registered types.
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
Popular Topics
Advertisement