🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Registering an void* pointer

Started by
5 comments, last by BornToCode 15 years, 11 months ago
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.
Advertisement
Since you spoke of a void pointer, do you mean that your c++ function looks like this:

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.
So is there anything in AngelScript that works like a void* does in C++
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

Thanks WitchLord. That is exactly what i was looking for.

This topic is closed to new replies.

Advertisement