Printf() and main() for Torquescript
by Crimson Rum Khulay Gin · in Technical Issues · 10/15/2007 (7:51 pm) · 4 replies
Hello everyone! :) I have 2 questions.
1.) Is there a function in torquescript that is similar to Printf() in C?
2.) How and where should I insert this function that simply displays a string... like "Hello World!!!"? Where would I insert that PrintF (if there is an equivalent in Torque) or any other function if I want it executed immediately upon load? I can't seem to find a default function similar to main().
All of these are assuming I have the only demo and I want to leave everything there intact except for the string I want displayed.
Thanks in advance everyone :)
1.) Is there a function in torquescript that is similar to Printf() in C?
2.) How and where should I insert this function that simply displays a string... like "Hello World!!!"? Where would I insert that PrintF (if there is an equivalent in Torque) or any other function if I want it executed immediately upon load? I can't seem to find a default function similar to main().
All of these are assuming I have the only demo and I want to leave everything there intact except for the string I want displayed.
Thanks in advance everyone :)
#2
2) The first main entry point after you've loaded a mission is an event callback handler called GameConnection::onClientEnterGame(), located in /example/starter.fps/server/scripts/game.cs.
It's very very important to note that echo is only going to display a message in your console, which can be brought up by hitting the ~ key (tilde). It's also very important to note that the entry callback location I list above is on the "server", while actual screen output such as a graphical user interface, etc. only happens on the console, so as you move forward in your learning, you will want to differentiate between the two often, and always know why you are writing script in certain files.
For example, the next logical question that most ask after you get the message to the console is "ok, how do I show this on screen in a GUI?"--and that takes a bit more understanding of the client-server architecture before it makes sense!
10/15/2007 (7:58 pm)
1) The command is Echo("Some Text");2) The first main entry point after you've loaded a mission is an event callback handler called GameConnection::onClientEnterGame(), located in /example/starter.fps/server/scripts/game.cs.
It's very very important to note that echo is only going to display a message in your console, which can be brought up by hitting the ~ key (tilde). It's also very important to note that the entry callback location I list above is on the "server", while actual screen output such as a graphical user interface, etc. only happens on the console, so as you move forward in your learning, you will want to differentiate between the two often, and always know why you are writing script in certain files.
For example, the next logical question that most ask after you get the message to the console is "ok, how do I show this on screen in a GUI?"--and that takes a bit more understanding of the client-server architecture before it makes sense!
#3
echo("Hello World!!!");
use the at "@" character to concatenate strings with variables. hit tilde(~) to open the console. enter the command into the console and hit enter. if you want the message to appear on the screen that's a bit more involved.
and the main() that you're looking for would be main.cs located in the same directory as the .exe file. This is the script file which controls what the engine does at startup.
10/15/2007 (8:00 pm)
Echo() and warn() are the two I am aware of. echo("Hello World!!!");
use the at "@" character to concatenate strings with variables. hit tilde(~) to open the console. enter the command into the console and hit enter. if you want the message to appear on the screen that's a bit more involved.
and the main() that you're looking for would be main.cs located in the same directory as the .exe file. This is the script file which controls what the engine does at startup.
#4
BTW... I don't know if there's a link posted somewhere here in the forums already, but I found this really great tutorial on how to build the simplest possible application in TorqueScript:
http://members.cox.net/midian/gamedesign/tgeintro.htm
This great tutorial was written by Sir Charles Patterson. Really great way to understand TorqueScript because it lets you start from the virtually nothiing (and no copy pasting of scripts here). :)
10/15/2007 (9:56 pm)
Thanks Stephen and Sean. Another question though... is there a delay function simmilar to the one in C? One that pauses the program in units of time? Ticks perhaps...BTW... I don't know if there's a link posted somewhere here in the forums already, but I found this really great tutorial on how to build the simplest possible application in TorqueScript:
http://members.cox.net/midian/gamedesign/tgeintro.htm
This great tutorial was written by Sir Charles Patterson. Really great way to understand TorqueScript because it lets you start from the virtually nothiing (and no copy pasting of scripts here). :)
Crimson Rum Khulay Gin