Registering an void* pointer
Is it possible to actually register an function with angelscript that takes a void*. What i am trying to do is be able to do something like this in AngelScript.
Sprite bird;
Image image;
RegisterGlobalObjects(bird);
RegisterGlobalObjects(image);
So basically what i want to do is be able to pass any objects to the function regardless of his type. and on the C++ side i can take care of it, by typecasting it to the right thing. Is that possible.
Since you spoke of a void pointer, do you mean that your c++ function looks like this:
Because if it does, you cannot cast it to the "right" class, because the "right" class can be anything. Even dynamic_casts won't work here (if you use polymorphism).
RegisterGlobalObjects(void*);
Because if it does, you cannot cast it to the "right" class, because the "right" class can be anything. Even dynamic_casts won't work here (if you use polymorphism).
Dude i know that it can be anything.All i want to know is if it is possible to pass an Object in Anglescript that way, where the object type does not matter.
Let me give a better example. Imagine i am doing this.
In one file i have this.
Map map;
RegisterGlobalObject("GameMap",↦);
Then in another file i want to be able to do this.
Map@ map = (Map@)GetGlobalObject("GameMap");
i just want to know if that is possible to do in Angelscript.
Let me give a better example. Imagine i am doing this.
In one file i have this.
Map map;
RegisterGlobalObject("GameMap",↦);
Then in another file i want to be able to do this.
Map@ map = (Map@)GetGlobalObject("GameMap");
i just want to know if that is possible to do in Angelscript.
You can register void* as your own type. You won't be able to cast within angelscript (but you probably knew that) but you will be able to store the void*, and pass it around and such.
You can use the any type that you'll find in the add_on folder. This is a complex container type that can hold any type.
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