Beginner's Headaches
by Joe Brown · 06/24/2011 (10:11 pm) · 1 comments
Hello GG community. I thought this would be a good time to introduce myself and share what I've learned while my short time scripting and such. I realize this probaly will not be much of a resource to our experienced senior members but it may offer some relief to any new members trying to hit the ground running like me.
If you look at my profile it shows I've been a member since 06 when I bought the binary version of 3D. Truth be told I only fooled around with the engine before moving on to try other stuff. After giving all the competitor's products a try I've decided to come back and make my stand with the Torque 3D engine.
Well with the new price point for the source who could beat it. All in all its a solid product that is lightweight enuff to make your hobbyist/indie aspirations find life.
So I would like to start with some tips that I've been finding along the way that make my growing pains bearable. Alot of you may be like well DUH! but I believe this will reach someone. Basically I am doing the "Jack of all trades" but I am more than competent in the art/music department. Its the code thats killer. But I refuse to give up and I'm finally starting to see I am learning. So here it goes.
1. Really consider choosing Torsion as your scripting enviroment. It was developed for Torque and it shows. If you havent noticed yet, within the Torque 3D Editors there are multiple jump points to take your scripting straight to Torsion. And the Indie price is stellar.
2. If your new then by all means create yourself a Full and an Empty template project. Then investigate what is not there in the Empty. And then read or reread the flow charts in the documentation to get a feel for how Tourque is executing things within your directory. As Mr. Acaster posted a few days ago pay attention to your exec scheme.
3. Exec,Exec,Exec. If you write a .cs file then somewhere you need to be telling the engine to exec it.
My first challenge to myself was to take an empty template and put in a simple mesh that would assume a player object so I could run it around my empty room. It took me 2 days to figure out exactly what the engine was trying to tell me it wanted in the code. And I locked myself out of the editor a few times which was frustrating but also taught me a great lesson. You can go into your levels/blank room.mis file and find what it saved that is breaking your code.
4. With the scripting I am writing and testing I save it in the root folder first. Then I exec with a console command in the editor. Then you'll see if the game wants anything to do with your piece of crap script your writing and get the same feedback torsion would give you. Use plenty of echo calls and youll see your functions and variables in action.
5. A great Script to read and reread for us newbies is the player.cs in your "scripts/server". And then look at your playerdata file in the "art/datablocks". Whats the first thing you should notice. They both have the same flippin name. And this happens alot. Now look at your "scripts/server/player.cs" again. Notice how the first half of the script is creating functions for "Armor::" and the latter half is using functions with "Player::". If your like me I wanted to know where this "Armor" was documented at because I could find docs on "Player". This brings up the next thing I think I learned. When your scripting functionality for your creation in one .cs file you can use functions from the object and also functions that come from the object Datablocks. And if you let yourself, you can mix this stuff up. (If your calling exec inside the console it will tell you these things sorta.) This is where "Armor::" comes into play. Look at your "DefaultPlayerData" in the "art/datablocks". You should see className = Armor;. LightBulb!(I think%). So I believe that "Armor" is a neat way of making a PlayerData.function call and Player lets you Player.Function. You will probaly need functions from both to create compelling gameplay and will be frustrated if your looking at the reference docs calling functions that the console is saying dont exist because you used them with the data instead of the object and vice versa.
6. If your still new to the Editors then heres a little tip. Say your using Blender and you want to export a .dae file to bring into Torque and attatch a player object to it to run it around the screen. This is actually pretty simple even if you dont know how to use the nodes yet. 1.In Blender add a new mesh (cube works fine). Then add a new material to it (default setting work). If you export the .dae file without the material it will not render in the editor or game. Now save the .dae file in your art/shapes.
2.Now using an empty template project you need to create a .cs declaring your new defaultplayerdata. Give it a class name and make sure to set "shapeFile" to where your mesh is residing.
3.Now add an exec call to your "art/databloks/datablockExec.cs" execin your defaultplayerdata.cs.
4. If your using torsion go ahead and make a release build. If everything works out you should be able to choose play. The cube should be there but you will be in spectator mode. Hit f11 and in the editor select your player tag. Now open the shape editor and there should be the cube. Now on your upper right little window select your "hints" tab. Double click the cam node. Abbra cadabbra a cam node you can select and move. There is now an asterick by your shape window header. Torque is telling you to save. Click the little disk icon to the lower right and walla you now have a cam node to attatch a 3rd person cam to. Try it out in the editor and you may have to tweak it more to get it right. Dont forget to save when you do find the setting.
5. Now if you rebuild the code you should spawn as the player object. Read the "core/scripts/server/spawn.cs" file and see if you understand why this works.
Well I have spewed enuff toxic info into the community. Its a frustrating journey and I am oddly enjoying every minute of it.
If you look at my profile it shows I've been a member since 06 when I bought the binary version of 3D. Truth be told I only fooled around with the engine before moving on to try other stuff. After giving all the competitor's products a try I've decided to come back and make my stand with the Torque 3D engine.
Well with the new price point for the source who could beat it. All in all its a solid product that is lightweight enuff to make your hobbyist/indie aspirations find life.
So I would like to start with some tips that I've been finding along the way that make my growing pains bearable. Alot of you may be like well DUH! but I believe this will reach someone. Basically I am doing the "Jack of all trades" but I am more than competent in the art/music department. Its the code thats killer. But I refuse to give up and I'm finally starting to see I am learning. So here it goes.
1. Really consider choosing Torsion as your scripting enviroment. It was developed for Torque and it shows. If you havent noticed yet, within the Torque 3D Editors there are multiple jump points to take your scripting straight to Torsion. And the Indie price is stellar.
2. If your new then by all means create yourself a Full and an Empty template project. Then investigate what is not there in the Empty. And then read or reread the flow charts in the documentation to get a feel for how Tourque is executing things within your directory. As Mr. Acaster posted a few days ago pay attention to your exec scheme.
3. Exec,Exec,Exec. If you write a .cs file then somewhere you need to be telling the engine to exec it.
My first challenge to myself was to take an empty template and put in a simple mesh that would assume a player object so I could run it around my empty room. It took me 2 days to figure out exactly what the engine was trying to tell me it wanted in the code. And I locked myself out of the editor a few times which was frustrating but also taught me a great lesson. You can go into your levels/blank room.mis file and find what it saved that is breaking your code.
4. With the scripting I am writing and testing I save it in the root folder first. Then I exec with a console command in the editor. Then you'll see if the game wants anything to do with your piece of crap script your writing and get the same feedback torsion would give you. Use plenty of echo calls and youll see your functions and variables in action.
5. A great Script to read and reread for us newbies is the player.cs in your "scripts/server". And then look at your playerdata file in the "art/datablocks". Whats the first thing you should notice. They both have the same flippin name. And this happens alot. Now look at your "scripts/server/player.cs" again. Notice how the first half of the script is creating functions for "Armor::" and the latter half is using functions with "Player::". If your like me I wanted to know where this "Armor" was documented at because I could find docs on "Player". This brings up the next thing I think I learned. When your scripting functionality for your creation in one .cs file you can use functions from the object and also functions that come from the object Datablocks. And if you let yourself, you can mix this stuff up. (If your calling exec inside the console it will tell you these things sorta.) This is where "Armor::" comes into play. Look at your "DefaultPlayerData" in the "art/datablocks". You should see className = Armor;. LightBulb!(I think%). So I believe that "Armor" is a neat way of making a PlayerData.function call and Player lets you Player.Function. You will probaly need functions from both to create compelling gameplay and will be frustrated if your looking at the reference docs calling functions that the console is saying dont exist because you used them with the data instead of the object and vice versa.
6. If your still new to the Editors then heres a little tip. Say your using Blender and you want to export a .dae file to bring into Torque and attatch a player object to it to run it around the screen. This is actually pretty simple even if you dont know how to use the nodes yet. 1.In Blender add a new mesh (cube works fine). Then add a new material to it (default setting work). If you export the .dae file without the material it will not render in the editor or game. Now save the .dae file in your art/shapes.
2.Now using an empty template project you need to create a .cs declaring your new defaultplayerdata. Give it a class name and make sure to set "shapeFile" to where your mesh is residing.
3.Now add an exec call to your "art/databloks/datablockExec.cs" execin your defaultplayerdata.cs.
4. If your using torsion go ahead and make a release build. If everything works out you should be able to choose play. The cube should be there but you will be in spectator mode. Hit f11 and in the editor select your player tag. Now open the shape editor and there should be the cube. Now on your upper right little window select your "hints" tab. Double click the cam node. Abbra cadabbra a cam node you can select and move. There is now an asterick by your shape window header. Torque is telling you to save. Click the little disk icon to the lower right and walla you now have a cam node to attatch a 3rd person cam to. Try it out in the editor and you may have to tweak it more to get it right. Dont forget to save when you do find the setting.
5. Now if you rebuild the code you should spawn as the player object. Read the "core/scripts/server/spawn.cs" file and see if you understand why this works.
Well I have spewed enuff toxic info into the community. Its a frustrating journey and I am oddly enjoying every minute of it.

Torque Owner Sean Brady
Plasis Games