Jump to content
  • Advertisement
Sign in to follow this  
noizex

Reloading modules on runtime

This topic is 2566 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,

Excuse me if this is lame question, I tried searching forums for topics regarding recompiling / reloading modules on the fly, something that is so important for scripting, and I couldn't find anything relating to my problem (I found good topic on serialization but thats not the case yet I think). I follow similar pattern as Angel Script's game engine, which means I register GameEntity class for AS then instantiate GameEntity from C++ and pass it to a constructor of controller script. So I have GameObject instance in C++ and it has a member "m_controller" that points to asIScriptObject.

So far I managed to reload all already loaded entity modules by building module again (if I'm correct it removes previous module). It works for all newly created objects but old ones remain unchanged (for example their 3d model or color doesn't change). So I can reload modules as many times as I want, but it only affects new instances of asIScriptObject.

What would be the best way of reloading already instantiated objects, so they change according to changes made in the script file? Lets assume I don't need to keep their current internal state for simplicity (I will worry about it later), but I want the changes that happen in class attributes or methods to be applied to all instances, not only new ones.

Share this post


Link to post
Share on other sites
Advertisement
To have already existing instances refresh with the recompile you need to find and replace them. This will obviously take a bit of an effort to implement, but unfortunately there is no easy way out as AngelScript doesn't keep track of all objects (only the ones that can potentially create circular references). Start with your own application objects (GameEntity), and then find all the script objects that you reference, then enumerate the properties of those objects to find any other instances they may reference, and so on.

If you wish to keep the attribute values when replacing the objects then there is a serializer add-on that will come in handy.

Regards,
Andreas

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!