Game Development Community

How can I execute .cs file in the console

by Roy Chan · in Torque Game Engine · 01/09/2003 (3:15 am) · 6 replies

Hi all,

I have followed the tutorial at
http://www.liquid.nq.net/tutorial/tutorial1.htm


But I don't know how to bring the console to execute .cs script at the TGE.

Looking forward to hear any reply

#1
01/09/2003 (3:26 am)
Bring down the console with the '~' key (''' key on UK keyboards)

For example, to run the "init.cs" file from the FPS example in the console, type...
exec("fps/client/init.cs");
Obviously, just substitute for the file you want to evaluate.

If you want to execute a function then you simply type the function such as ...
MyFunction(123);

- Melv.
#2
01/09/2003 (9:25 am)
Just to add to that, once you type something and enter it in the console, you can use the up arrow to cycle through things you've already entered. Saves a little typing.

edit: It will only cycle through things entered for the current launch of the game. It clears that list out after you exit.

-Sabrecyd
#3
01/10/2003 (12:40 am)
I don't know why some strange character added to my scripts when I execute the script in the console.


My original script (Part of)
============================
function getHours(%seconds)
{
%val = %seconds / 3600;
%val = mfloor(%val); //mfloor rounds numbers
Return %val;
}

Error Message (Part of)
=======================
fps/server/scripts/tutorial1.cs Line: 5 - Synatx error.
>>> Advanced script error report. Line 9.
>>> Some error context, with ## on sides of error halt:
%Val = mfloor(%val); //mfloor rounds numbers
Return %val:##
##
}
#4
01/10/2003 (12:45 am)
%Val = mfloor(%val); //mfloor rounds numbers 
Return %val:
- You've used "%Val", it looks like it should be all in lower-case.
- The keyword "return" should be in all lower-case.
- You've put a full colon ":" at the end of the return statement, you should of put a semi-colon ";"!

Simply use...
return mFloor( %seconds / 3600 );
You should really be more careful with cases or adopt a more consistent style so that simple mistakes like these don't happen. Just a friendly suggestion Roy. :)

- Melv.
#5
01/10/2003 (1:23 am)
Yeah, the colon seems to be the problem...
And you *should* force yourself to be careful with upper-/lowercase, although the Torque scripting engine isn't case-sensitive at all (so the uppercases above won't be causing any errors... but still... ;)

On a sidenote: JEEZ! this is my 1000th post on the GG forums... beer for everyone!! ;)
#6
01/10/2003 (1:49 am)
And everyone one of them that I've read has been helpful!

Thanks Stefan, *beers* to you!