Game Development Community

Is there a "delay" or "pause" script command?

by Stephen Clark · in Torque Game Engine · 07/23/2003 (2:12 pm) · 12 replies

All i need to do is pause execution of my script and then continue with the script in X millis or whatever. Is there some way to do this w/o scheldule() as thats not really what I want.

#1
07/23/2003 (2:16 pm)
Schedule is the only way
#2
07/23/2003 (2:18 pm)
Damn...

thanks for the quick response LabRat

-s
#3
06/11/2004 (3:35 pm)
Hi--
I'm asking this question again, since it's been almost a year and maybe somebody has added a "wait" or "pause" script command since then. Does anyone know of a simpler way to pause script execution, other than using "Schedule?" Seems to me I'm adding a few lines of unnecessary code every time I try to pause the script's execution--and I tend to write long scripts (for long missions) which translates to lots of extra lines.
Has anyone in the development area come up with a simpler solution to this--e.g., "wait(x);" where "x" is milliseconds? It's common with other scripting engines... I'd appreciate any guidance you TorqueScript veterans can offer. :)
#4
06/11/2004 (4:03 pm)
What use would that be? Freezing the game, the schedule is there for that purpose withour freezing your game and making it play at 2 fps. Scripts are not multithreaded, thus if you pause execution you pause the game. Torque runs in a single thread completely.
#5
06/11/2004 (7:58 pm)
Wow! Didn't realize that. I'm used to working with a scriptor that employs up to 30 different routines all at the same time, each independently controlling different aspects of the game including the behavior of different units, polling for distances and triggers, and so forth. Seems to me that having it run in a single thread is incredibly limiting. Maybe I'm just not used to that kind of approach or something, but I have a hard time imagining how I can do some of the independent AI subroutine kind of stuff that I'm capable of with other scriptors.

Anyone know if it's possible to graft Lua scripts onto the Torque engine, or if anyone has jury-rigged Torque Script to allow multiple routines and/or threads? I love Torque's 3D engine and I'm really looking forward to the new shader engine, but I had no idea that I'd be so limited in threading and unit control, and thus AI. Now I begin to see why Torque scripts are recommended to be no longer than 1000 lines! :(

Or maybe I'm just misinterpreting this. Although I've done a total conversion and some major modding, this is my first experience with Torque and I'm only a novice C++ programmer. Any guidance on this would be appreciated!
#6
06/11/2004 (8:07 pm)
I should make it clear that I'm NOT referring to multiplayer games but instead to a single-player campaign mode, where it's player-versus-computer. I've found that, by using a number of different threads (only a few of which are necessarily running at any given time), I'm able to take the old, boring campaign mission way beyond the dull script that typified single-player games of the past (like a lot of the LucasArts games, for instance), and make them far more variable and unpredictable, with branching outcomes and a variety of potential solutions (or even *goals*) for each mission. Likewise, multi-routine scripts can offer a lot more flexibility in terms of AI. I understand that this kind of thing would wreak havoc with the syncing of multiplayer games, but it can be a powerful tool in the creation of interesting and re-playable single-player campaigns.
#7
06/12/2004 (7:25 am)
Many many games have been made single-threaded, and very good ones at that. You just have to change your way of thinking. Instead of making one long, multithreaded script, try making multiple subroutines, small functions. Have one function schedule a different function to run. Use events... like when the player comes into view, have the enemy duck and cover or whatever. There's lots of events, and you can always create new ones (with some coding). In general, just think out of the box... it's good for you :)
#8
06/12/2004 (9:01 am)
John's right. :)

Perhaps some future version of the scripting engine will do that sort of neat threading, but for now you'll have to do it all in one go like the rest of us... ;)

You could try using the Python resources if you wanted.
#9
06/12/2004 (11:32 am)
Thanks, guys!

I'd been thinking about it last night and realized that some of the object-based settings/events and the use of various functions may serve much the same purpose as the multithreaded scripts I was talking about.

I'm also quite new to Torque, so you're right, it's a new way of thinking and I'll probably be able to learn how to do most of the things I did before, but just do them differently. :) Using 3DGPAI1, I'm picking up a lot in short order, so that's a big help!

I'll also take a look at Python--thanks again.
#10
07/17/2004 (6:26 am)
Hmm...I'm starting to look into this as well. We're using the RPGDialog resource and would like the game to somewhat pause while the Dialog boxes are up. Any thoughts?
#11
07/17/2004 (6:37 am)
@Chris: Not sure what you mean by "somewhat pause" but you can always set a global flag like $InGameDialog to true and not do any AI processing when that flag is set. If you were managing all the AI through something like AIManager then you could do something as simple as this:
function AIManager::think(%this)
{
   if(false == $InGameDialog)
   {
      if (!isObject(%this.player))
         %this.player = %this.spawn();
   }
   %this.schedule(500,think);
}
#12
07/17/2004 (4:14 pm)
Hmm, that might work. Basically that's what we're looking for. Something that will "pause" the game while the player is looking through inventory or talking with an NPC so a wandering mob doesn't start chewing on them :)