Simple "Doh!" solutions.
by David Roberts · in Torque Game Builder · 02/27/2005 (7:37 am) · 13 replies
Hi,
Having had the chance to play around with T2D for a little while (not as I much as I would like though!), I'd thought I'd post a couple of problems I have come across during my learning experience. As I am learning TorqueScript properly for the first time from a C++ developers perspective, they are mainly silly errors but nonetheless had me scratching my head for five mins until I had a "Doh!" moment.
Huh?) You make changes to the code and nothing seems to be different from the previous build.
Doh!) Torque is loading from the .cs.dso file and the .cs file you have saved contains errors.
Huh?) You have commented out code with a '/*' block for testing purposes.
Doh!) TorqueScript only supports '//' comments as far as I am aware.
Huh?) Images are not being rendered in the correct order.
Doh!) .setlayer(0) is the topmost layer of the rendering z-order in default settings.
It's always seems to be the simple errors that catch me out! I'll add more as I get 'em! :-)
Everybody feel free to contribute with problems where you have kicked yourself with how simple the solution is!!!
- Dave
Having had the chance to play around with T2D for a little while (not as I much as I would like though!), I'd thought I'd post a couple of problems I have come across during my learning experience. As I am learning TorqueScript properly for the first time from a C++ developers perspective, they are mainly silly errors but nonetheless had me scratching my head for five mins until I had a "Doh!" moment.
Huh?) You make changes to the code and nothing seems to be different from the previous build.
Doh!) Torque is loading from the .cs.dso file and the .cs file you have saved contains errors.
Huh?) You have commented out code with a '/*' block for testing purposes.
Doh!) TorqueScript only supports '//' comments as far as I am aware.
Huh?) Images are not being rendered in the correct order.
Doh!) .setlayer(0) is the topmost layer of the rendering z-order in default settings.
It's always seems to be the simple errors that catch me out! I'll add more as I get 'em! :-)
Everybody feel free to contribute with problems where you have kicked yourself with how simple the solution is!!!
- Dave
About the author
#2
my mistake: echo("You have selected" %obj);
solution: you need to seperat with something like @ or SPC
echo("You have selected" SPC %obj);
or
echo("You have selected " @ %obj);
I know this is the problem when I look in the console and see ## near my echo statements. Doh!
Another mistake I used to do is not delete the config.cs and config.cs.dso files in the client folder when you change default.bind.cs in TGE to try and change control bindings.
Also ALOT of people I see out there make the mistake of changing controls in the config.cs file rather then the default.bind.cs file. it works but they will eventually see that this is the place the engine writes controls So players can change controls on the fly.
02/27/2005 (9:46 am)
I forget to add commands in between my echo statements and wonder why it doesn't work.my mistake: echo("You have selected" %obj);
solution: you need to seperat with something like @ or SPC
echo("You have selected" SPC %obj);
or
echo("You have selected " @ %obj);
I know this is the problem when I look in the console and see ## near my echo statements. Doh!
Another mistake I used to do is not delete the config.cs and config.cs.dso files in the client folder when you change default.bind.cs in TGE to try and change control bindings.
Also ALOT of people I see out there make the mistake of changing controls in the config.cs file rather then the default.bind.cs file. it works but they will eventually see that this is the place the engine writes controls So players can change controls on the fly.
#3
02/27/2005 (9:54 am)
I'm really good at loading the relevant scripts into UltraEdit or BBEdit and then copying the directory and all of the files for use into a new project directory. So when I run everything none of my changes show up (because my scripts are pointing at the original directory instead of the new project directory).
#4
It wasn't till I read the first Doh! did I realize it was because the new script had errors and it was defaulting to the .dso that didn't have any.
It's kind of funny when you find things out that you were not even looking for!
02/27/2005 (12:27 pm)
I have been having issues where i make changes to the code, they don't work and the console is reporting everything fine. It wasn't till I read the first Doh! did I realize it was because the new script had errors and it was defaulting to the .dso that didn't have any.
It's kind of funny when you find things out that you were not even looking for!
#5
If you try to start the engine and find yourself looking at an ugly error screen, its probably because you already have another copy of T2D.exe running already. It's easy to lose track of whats running when you have a myriad of windows open at once.
02/28/2005 (6:45 am)
Heres a dumb one that i'm guilty of on occaision..If you try to start the engine and find yourself looking at an ugly error screen, its probably because you already have another copy of T2D.exe running already. It's easy to lose track of whats running when you have a myriad of windows open at once.
#6
EDIT: also remember the "##" are next to where the error catches up with itself... usually my errors lie in a simple ";" forgotten since I typed script in too quick, though the "##" will be in a line after it because thats when it catches up with it.
02/28/2005 (6:50 am)
First thing I do in Torque 2d and Torque 3d when I run a test is always open the console and scroll through it real quick looking for red text... can't say how many hours that would've saved me and has saved meEDIT: also remember the "##" are next to where the error catches up with itself... usually my errors lie in a simple ";" forgotten since I typed script in too quick, though the "##" will be in a line after it because thats when it catches up with it.
#7
Although I am still lost on the something.##w#hatever error
02/28/2005 (9:16 am)
Thanks Matthew. I was wondering exactly when the ## showed up where the error was. I figured it was just on the line because I was having errors like something.##w#hatever or ##; ## and I couldnt figure it out.Although I am still lost on the something.##w#hatever error
#8
02/28/2005 (9:28 am)
Thats usually missing a ";" ... a "}"... or similar errors... so when you reference another object it realizes somethings wrong (more or less - I beleive) ... or it could be an invalid object (though when you know the object is correct and what your referencing is correct - those should be the first thing you check - look for a ";" or "}" gone AWOL
#9
02/28/2005 (9:48 pm)
I fixed the problem and it wasn't even related to that line or the decloration of the object itself so I had no idea why It came up like that. The problem was actually the line above(i think) missing a opening "("
#10
03/01/2005 (7:05 am)
Ahh a "(" that slipped my mind... though I would say that falls under the same elusive missing tags... ";" "}" "(" ")" ... usually a tag that starts or ends something ... glad you found it :)
#11
03/01/2005 (8:02 am)
I'm good at swapping one {} with a (), and depending on the orientation of the seat to the flat panel monitor, those can look almost identical.
#12
Another thing that I wish I would've known originally starting scripting in Torque...
You cannot pass arrays...
%data[0] = 1;
%data[1] = 2;
etc... that works, but cannot be passed.
one workaround to this is ScriptObjects
%data = new ScriptObject();
%data.contents[0] = 1;
%data.contents[1] = 2;
(the "contents" part can be whatever)...
etc... this can most definately be passed :)
another nice thing is you can make it as many dimensions as needed
for ex:
%data = new ScriptObject();
%data.contents[0] = new ScriptObject();
%data.contents[0].contents[0] = new ScriptObject();
so you can pass some hefty info arround if needed. Search resources for another way and more examples.
03/01/2005 (10:41 am)
Lol I can concur with that David... I have a laptop and flat panel monitor at home so that happens to me often. The resolution has to be just right also or text even begins looking a bit choppy too.Another thing that I wish I would've known originally starting scripting in Torque...
You cannot pass arrays...
%data[0] = 1;
%data[1] = 2;
etc... that works, but cannot be passed.
one workaround to this is ScriptObjects
%data = new ScriptObject();
%data.contents[0] = 1;
%data.contents[1] = 2;
(the "contents" part can be whatever)...
etc... this can most definately be passed :)
another nice thing is you can make it as many dimensions as needed
for ex:
%data = new ScriptObject();
%data.contents[0] = new ScriptObject();
%data.contents[0].contents[0] = new ScriptObject();
so you can pass some hefty info arround if needed. Search resources for another way and more examples.
#13
03/01/2005 (11:52 am)
ScriptObjects are definately a very powerfull tool. Generally they get ignored in TGE, as their generic nature doesn't make them stand out as a usefull tool.
Associate Melv May
Always look in the console (or the "console.log" file if something unexpected happens!
- Melv.