Jump to content
The Dark Mod Forums

Recommended Posts

Posted

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...)?

 

Posted

 

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. 

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

    • JackFarmer

      Happy Labour Day, my taffing taffers & hard working mapping friends!
      And remember the poor souls who, within the Inventors’ organization, labor under Jonus’s yoke to ensure the success of that very guild! Always remember the hard workers!
      · 2 replies
    • datiswous

      Is there a script command to make a screenshot?
      I just though it could be interesting to be able to create a screenshot at a certain point in time. Then use that screenshot possibly in a debrief.
      I guess the second question is: Can you use a (in-game made) screenshot in a (debrief) gui?
      · 1 reply
    • Bikerdude  »  Display Cement

      So what type, and what ratio of portland to sand 😏
      · 1 reply
    • JackFarmer

      Our esteemed professional mapping predecessors from 20 years ago faced the same challenges we do today!
      · 2 replies
    • snatcher

      TDM Modpack 5.1 is out!
      · 0 replies
×
×
  • Create New...