Saving script execution

Hello,

I’m working on a project which requires save to be availiable anytime.

But I run “triggers” (self-made class Trigger) on this map, i.e; actions performed when a game-event is fired.
For example, a timer runs, indicating game time. An event can be “Every 2 seconds of game time” and the correspondaing trigger will be fired every 2 seconds.
This trigger will (or not) execute a method to determine whether the conditions are met for it to run. If yes, it will execute another method, representing the actions, on its own thread.

But if the game is saved, and the trigger’s actions are running, I need to save the actual context of the trigger (i.e., of the thread) and which method is being executed in the action method.
I also need to save which triggers are running, even if they just responded to the event and ran nothing.
Condition method has the same problem.

How would one achieve this?

Is there no other option than using a self-made script language, seen as self-made bytecode?

Thanks!

Well the most simple solution would be to have some kind of trigger /whatever registry calss, where all objects have their internal state. Then you could just save this object.

If your internal state of the triggers is only the stacktrace of a workerthread, you are going to have a bad time.

@Empire Phoenix said: Well the most simple solution would be to have some kind of trigger /whatever registry calss, where all objects have their internal state. Then you could just save this object.

If your internal state of the triggers is only the stacktrace of a workerthread, you are going to have a bad time.

I’d second this… the worker thread should be handed the data from whatever object you are using to represent these events/triggers/etc. Save the object/retrieve the object… ignore the worker, as whatever is representing the trigger should be aware of it’s current state: queued, executing, finished, etc.