Game Development Community

Scheduling text to show up on screen at a certain time?

by Chris · in Torque Game Engine · 05/24/2009 (5:14 pm) · 5 replies

Hey guys, I'm trying to get a line of text using the CenterPrint function to show up 25 seconds into the game. For some reason the code I currently have is just making the text pop up right when the game starts. Can anyone tell me what I'm doing wrong here?

serverConnection.schedule( 25000, clientCmdCenterPrint( "Orderly: Alright, it's time to see the doctor.", 3, 15));

#1
05/24/2009 (5:46 pm)
the syntax for this form of schedule() is
object.schedule(delay, method name, arguments to method...)

the way you have clientCmdCenterPrint() in there,
it's actually calling that function at the time you issue the schedule and using whatever the return value is as the method name.

also, there's another form of schedule which doesn't need an object to call it on, which seems a bit more appropriate in this case.
try this:

schedule(25000, 0, "clientCmdCenterPrint", "orderly etc..", 3, 15);

also,
i'm unfamiliar w/ clientCmdCenterPrint, but it's likely just a wrapper around some other routine like maybe "centerPrint()". if that's the case i would recommend calling the real core function directly rather than the clientCmd wrapper.


#2
05/24/2009 (6:09 pm)
What Orion said about the schedule syntax...

If you really have to send a clientCmd to post a message, then this is how you send a Center/Bottom print message (I think):
commandToClient(%client, 'BottomPrint', %message, %time, %length);
%message = your text string
%time = how long the center/bottom print GUI stays on the screen
%length = the number of lines the GUI will take up on the screen.

But truthfully, I can't really think of a situation where you would need to send such a message as a Client Cmd, you should be able to call it directly so long as you know who the client is.
CenterPrint(%client, %message, %time, %length);
#3
05/24/2009 (7:36 pm)
Thanks for the replies as always guys!

Orion, I've changed the code to the following:

serverConnection.schedule( 10000, 0, clientCmdCenterPrint, "Orderly: Alright, it's time to see the doctor.", 1, 55);

Unfortunately now nothing shows up! I've been fiddling with it trying to figure out why but to no avail. Any help is greatly appreciated as always.
#4
05/24/2009 (7:40 pm)
try removing the "serverConnection." at the beginning.
#5
05/24/2009 (7:47 pm)
Ah ha! That was it, thanks as always Orion. Wish I could buy ya a beer!