🎉 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!

Class slot variables

Started by
0 comments, last by WitchLord 9 years, 12 months ago

Hello,

I'm wondering if it's possible to assign some scripted user-specific variable to a class instance ?

For example, I have a C++ registered class, an instance is created locally in a function :

I have MyClass.origin variable (registered from C++) and I want to save it to MyClass.old_origin (without registering old_origin from C++), will AngelScript create a new variable slot in the class ?

In Squirrel you can't do "class.old_origin <- class.origin", it will simply print that class instances doesn't support the new slot operator. In some games you can do this (o/c they have their own compiler and ScriptVariable class ha).

I'm just wondering because Squirrel and AngelScript are the best interpreter for me and I need to choose which is the most flexible.

Advertisement

The layout of members of classes are defined at compile time. It is not possible to add members to an existing instance of a class at run-time (unless you implement hot-loading where the script is modified and recompiled while persisting the existing state).

If you need to dynamically add data to classes, I suggest you include a dictionary in the class, and add the data to that one instead of the class itself.

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