Jump to content
  • Advertisement
Sign in to follow this  

Serializer add on with game example

This topic is 1771 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

I wanted to be able to load angelscript files when they have been changed while the game is running. My code is heavily based of the angelscript game example.

I stumbled across the serializer add on and thought that might be what I am looking for. Even though it says global values it does have the AddExtraObjectToStore option which I could add the controllers used in the example. There are a few things that have me a little confused.

The compile function used in the documentation is pretty vague.
So I assumed I would just delete the module and use the builder add on after .
Though what I have found is just using the DiscardModule function of the engine without rebuilding or doing anything else. Everything keeps running. I thought it would crash or give strange results. So I checked the return value from DiscardModule which was 0 so it found the module and I even made it call it twice to check if it did anything and the first one return 0 as expected the second time it returned -14  which was expected as it was deleted. Though Everything keeps running fine.

Anyway I added the rest of the code for the serializer and the builder and I receive no errors but it has no effect on the behavior. the builder completes with no errors and I know all build and serialize functions are getting called. It is really confusing .


also there is a slight error in the documentation I think. I think modStore is meant to be backup.

// Tell the serializer how the user types should be serialized
  // by adding the implementations of the CUserType interface
  CSerializer backup;
  backup.AddUserType(new CStringType(), "string");
  backup.AddUserType(new CArrayType(), "array");
  // Backup the values of the global variables

I searched online and I seemed to find a few people who said they had the hot loading functionality using angelscript. Unfortunately no where said how.

Share this post

Link to post
Share on other sites

AddExtraObjectToStore is used exactly for what you imagined it, and can definitely be used for the controller objects.


To recompile your module you can simply use the CScriptBuilder add-on to build the script again. It will automatically discard the old content of the module and rebuilt it.


Discarding a module will only remove the content so it won't be visible from the application. If there are object instances that are still alive and use the old code, they will continue to work for as long as they live. The old content will be freed when it is no longer used by any objects.


The serializer will create new instances of the objects using the new code from the module. You should replace the old controller instances with the new controller instances to see the changes done in the script.




You're right about the mistake in the documentation. I'll have it corrected, thanks.

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!