Posted about this earlier... but no responses..
by Jeff Thomann · in Torque Game Engine · 12/29/2004 (11:01 am) · 10 replies
The other posting was here:
http://www.garagegames.com/mg/forums/result.thread.php?qt=24418
that post was more about the book than about the engine... this one's related, but is more about the engine itself... How the @#%@#% do you set up your own scripts to work with the engine, and how or do you need to compile a blank TGE.exe like the one that the scripts are using in 3d Game Programming All In One? I've got the book, and am cruising through it and have looked at a few tutorials, but am still having troubles trying to get down the basics of setting up the engine to take my cs scripts.... anybody have tips, tutorials or something?
http://www.garagegames.com/mg/forums/result.thread.php?qt=24418
that post was more about the book than about the engine... this one's related, but is more about the engine itself... How the @#%@#% do you set up your own scripts to work with the engine, and how or do you need to compile a blank TGE.exe like the one that the scripts are using in 3d Game Programming All In One? I've got the book, and am cruising through it and have looked at a few tutorials, but am still having troubles trying to get down the basics of setting up the engine to take my cs scripts.... anybody have tips, tutorials or something?
About the author
#2
I'm working on a project designer for Torque that creates the Design Documentation and the basic file structure and files from answering a few questions.
12/29/2004 (6:35 pm)
I'm currently reading that book and scripting / writing your own and implementing them is handling in Chapter 4 and 5 where I'm currently at.I'm working on a project designer for Torque that creates the Design Documentation and the basic file structure and files from answering a few questions.
#4
12/30/2004 (5:29 am)
Thanks! That really helps a lot. Ken, if you are reading this, you may want to add this sort of informational info in the next version of the book.
#5
I'd really like to start with a bare bones, hello-world script, and know that there's no other scripts being loaded before mine gets underway! So I'd be really interested in knowing... is there any way to produce something like tge.exe from the 1.4 sources, so I can start my scripting from scratch? Any pointers would be much appreciated.
01/25/2005 (1:55 pm)
Hi folks, I'm interested in an answer to the same sort of question... I've got the sources for 1.4 compiled, and the demo apps are working on my machine... I've even made some changes to make it cope more gracefully with my multiheaded setup. But I really liked the way that the book starts with a completely minimal app. I've found working from the demo apps pretty overwhelming, because the codebase is so big and there are so much stuff in the sample folders. Even the demo app doesn't just link against the library and load a script, it's got piles of source files to link in.I'd really like to start with a bare bones, hello-world script, and know that there's no other scripts being loaded before mine gets underway! So I'd be really interested in knowing... is there any way to produce something like tge.exe from the 1.4 sources, so I can start my scripting from scratch? Any pointers would be much appreciated.
#6
01/25/2005 (3:47 pm)
Is the 1.4 SDK released ??
#7
01/25/2005 (3:50 pm)
Ahem, no, sorry, that's what I get for typing while eating my dinner! I meant 1.3...
#8
There are some basic starter things. If you just want to build from scratch, replace the main.cs in the root example directory and go for it. I personally think it's easier to start messing from within the existing framework, but whatever helps you learn... :)
01/27/2005 (5:29 pm)
There isn't a library to link against, actually. Torque is not a library. :)There are some basic starter things. If you just want to build from scratch, replace the main.cs in the root example directory and go for it. I personally think it's easier to start messing from within the existing framework, but whatever helps you learn... :)
#9
When you run this executable, what it does is go look for a file named main.cs, which it then executes. Within main.cs, you can execuate anything you want (take a look at the demo one, you probably won't need to change it any.) But usually, it calls some server.cs and client.cs. Those exec code for the server and client respectivly, plus anything else you tell them to exec.
In general, the majority of your script files you are going to want to exec in server.cs. Basically, what physical file a function is in doesnt mean anything. As long as you exec the file, you will have access to that function in the console or anywhere else you want it.
Really though, you are going to want most of the things that are included with the fps demo. I would just start working from there, adding features, and as you get further along you'll see what files do what and what you can eliminate. At a minimum, you'll want everything in common, main.cs, server.cs and client.cs. He talks about all of these later on in the book in detail, but you can really just copy them from the example.
Good luck! I know it seems a lot to get into at first, but you'll catch on quickly.
01/30/2005 (5:23 pm)
The basic thing that it took me a while to figure out...so you compile the torque engine into some file, generaically called torque demo.exe.When you run this executable, what it does is go look for a file named main.cs, which it then executes. Within main.cs, you can execuate anything you want (take a look at the demo one, you probably won't need to change it any.) But usually, it calls some server.cs and client.cs. Those exec code for the server and client respectivly, plus anything else you tell them to exec.
In general, the majority of your script files you are going to want to exec in server.cs. Basically, what physical file a function is in doesnt mean anything. As long as you exec the file, you will have access to that function in the console or anywhere else you want it.
Really though, you are going to want most of the things that are included with the fps demo. I would just start working from there, adding features, and as you get further along you'll see what files do what and what you can eliminate. At a minimum, you'll want everything in common, main.cs, server.cs and client.cs. He talks about all of these later on in the book in detail, but you can really just copy them from the example.
Good luck! I know it seems a lot to get into at first, but you'll catch on quickly.
#10
A couple of other things you should look out for:
Torgue compiles script into byte code before it executes it. It checks the date stamp of the byte code against the date stamp of the script (.cs) file. If the byte code is older then it recompiles it otherwise it assumes it's current. This usually works fine but if you are copying files about whilst testing it's possible to get into a situation where the byte code is newer than the .cs file. In that case the code won't be recompiled and you may end up wondering what is going on. If you ever get into that state then I recommened deleting the byte code and trying again.
Secondly if there is a syntax error in the script then when torque attempts to compile the byte code it will fail and report an error message to the console and the log. Unfortunately it then aborts compiling the byte code but continues with program execution. So what then happens is the script loads the old version of the byte code and executes that instead of your new script:( This can be very confusing because when you first start making changes to scripts you tend to make a lot of syntax errors. Then if you are not checking the console or log it looks like your changes are not having any effect! I recommend that after changing a script the first thing to do is open the console and look for error messages.
Actually what I did was to find in the source where the error is generated and stick an assert in there. This opens a dialogue in windows which shows the error message and then aborts the code. Much easier than rummaging through the console trying to find the syntax error messages.
Finally be aware that script has fairly limited error reporting with regards to variables. For example it won't fail if you miss of the % or $ of the front of a variable in your script. It compiles executes and then reports an error to the console at run time. If you make a spelling mistake when referencing a variable Torque creates a new one and doesn't report an error. It's all part of the joy which is working in script.
I think Torque is a good scripting langauge though once you know how to work it.
01/30/2005 (5:54 pm)
Jeff,A couple of other things you should look out for:
Torgue compiles script into byte code before it executes it. It checks the date stamp of the byte code against the date stamp of the script (.cs) file. If the byte code is older then it recompiles it otherwise it assumes it's current. This usually works fine but if you are copying files about whilst testing it's possible to get into a situation where the byte code is newer than the .cs file. In that case the code won't be recompiled and you may end up wondering what is going on. If you ever get into that state then I recommened deleting the byte code and trying again.
Secondly if there is a syntax error in the script then when torque attempts to compile the byte code it will fail and report an error message to the console and the log. Unfortunately it then aborts compiling the byte code but continues with program execution. So what then happens is the script loads the old version of the byte code and executes that instead of your new script:( This can be very confusing because when you first start making changes to scripts you tend to make a lot of syntax errors. Then if you are not checking the console or log it looks like your changes are not having any effect! I recommend that after changing a script the first thing to do is open the console and look for error messages.
Actually what I did was to find in the source where the error is generated and stick an assert in there. This opens a dialogue in windows which shows the error message and then aborts the code. Much easier than rummaging through the console trying to find the syntax error messages.
Finally be aware that script has fairly limited error reporting with regards to variables. For example it won't fail if you miss of the % or $ of the front of a variable in your script. It compiles executes and then reports an error to the console at run time. If you make a spelling mistake when referencing a variable Torque creates a new one and doesn't report an error. It's all part of the joy which is working in script.
I think Torque is a good scripting langauge though once you know how to work it.
Torque 3D Owner Billy L
open your favorite editor , notepad or simular.
type
function Hello()
{
echo("Hello there ");
}
Save the script in starter.fps/server/scripts/ call the script hi.cs
edit starter.fps/server/scripts/game.cs
add after exec ("./aiplayer.cs");
exec ("hi.cs");
launch the game , open console and type hello();
If you done everything right you should get the answer Hello there