Jump to content
The Dark Mod Forums

eachFrame


Oktokolo

Recommended Posts

This control structure isn't really documented in the wiki and seems to run its code block each frame (what a surprise). It looks like the loop can be exited with break.

But if a function containing an eachFrame code block is called multiple times somehow, could that actually lead to multiple instances of the eachFrame code block running in parallel every frame?

Should i use an alreadyRunning flag for eachFrame blocks that can somehow be started by the player (by trigger, stim, objective...)?

 

Link to comment
Share on other sites

 

19 hours ago, Abusimplea said:

This control structure isn't really documented in the wiki and seems to run its code block each frame (what a surprise). It looks like the loop can be exited with break.

in original idtech4 eachFrame is just a Macro of a infinite for loop with a one frame pause

#define eachFrame	for( 0; 1; waitFrame() )

In case you don't know what DoomScript Macros are they are just like C macros.

Is like doing 

while(true) {
// do something 

	waitframe();
}

I have not coded in DoomScript for ages now but I assume eachFrame loop, can be exited with break or with return, just like in C/C++. 

19 hours ago, Abusimplea said:

But if a function containing an eachFrame code block is called multiple times somehow, could that actually lead to multiple instances of the eachFrame code block running in parallel every frame?

Not sure about this but I think functions with eachFrame loops, need to be called in a different thread, using the "thread" keyword, like done with "infinite" while loops, If not, I think it will run on the main thread, stall the game and block other loops. but like I said not 100% sure.

19 hours ago, Abusimplea said:

Should i use an alreadyRunning flag for eachFrame blocks that can somehow be started by the player (by trigger, stim, objective...)?

 Also not sure if I understand the question but are you asking how to run different loops concurrently? If yes, then use script threads.  btw script thread's, is not multithreading ala multi CPU's, is multiple threads running on a single CPU.

Hope this help. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • Petike the Taffer

      I've finally managed to log in to The Dark Mod Wiki. I'm back in the saddle and before the holidays start in full, I'll be adding a few new FM articles and doing other updates. Written in Stone is already done.
      · 1 reply
    • nbohr1more

      TDM 15th Anniversary Contest is now active! Please declare your participation: https://forums.thedarkmod.com/index.php?/topic/22413-the-dark-mod-15th-anniversary-contest-entry-thread/
       
      · 0 replies
    • JackFarmer

      @TheUnbeholden
      You cannot receive PMs. Could you please be so kind and check your mailbox if it is full (or maybe you switched off the function)?
      · 1 reply
    • OrbWeaver

      I like the new frob highlight but it would nice if it was less "flickery" while moving over objects (especially barred metal doors).
      · 4 replies
    • nbohr1more

      Please vote in the 15th Anniversary Contest Theme Poll
       
      · 0 replies
×
×
  • Create New...