Jump to content
  • Advertisement
Sign in to follow this  
Kdeon

Class slot variables

This topic is 1421 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Edited by Kdeon

Share this post


Link to post
Share on other sites
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. 

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!