Jump to content

  • Log In with Google      Sign In   
  • Create Account

- - - - -

variable persistence and does it make sense to have an 'idle loop'


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 iraxef   Members   -  Reputation: 348

Like
0Likes
Like

Posted 18 December 2013 - 09:00 PM

Does it make sense to keep a script (context) running in an 'idle loop' - that is, if it doesn't need to do anything, then Suspend() itself (through a registered function).. and when it needs to do some work, to do that and go back to being idle (how would you even signal it that it needs to do some work.. through a global variable which is shared amongst all contexts of that script module?)? That way that function that you Execute()'d would maintain its local variables (because you keep it running).

 

Or is it idiomatic for AngelScript to maintain state through global variables?

 

How should you maintain state? Or is it expected that C++ maintains whatever game state and each time a script function runs, it queries whatever it needs to (through registered functions/objects) in order to gather the necessary variables to do its work?

 

Thank you.



Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3352

Like
1Likes
Like

Posted 19 December 2013 - 07:43 AM

Think of your first alternative as a parallel thread in your application. The application will allow the context to execute for a while, then the context will wait (suspend) until it is time to execute again.

 

The other option is more like to event handling. Anytime there is an event in the application, the context is executed to handle that even and may use global variables (or properties registered by the application) to keep state information between executions.

 

 

Both options are perfectly viable with AngelScript, and it will only depend on your preference.

 

In my opinion the second option is easier to implement and manage, for the same reason that a singlethreaded application is easier to implement and manage compared to a multithreaded application.


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS