Game Development Community

torque wont let me make my own scripts ???

by Matthew Warner · in Torque 2D Beginner · 09/08/2014 (12:48 am) · 9 replies

Okay, I have been programming for about 12 years now. Started with Pascal, moved into c, c#, and c++. I develop on OS X 10.9 Mavericks. I downloaded Torque 2D and followed the instructions that basically said open the xcode project file and hit run. So I did that and everything went fine. I saw a truck I clicked and it moved. Okay not a problem. But now I cannot figure out where that game's script is to see how it works... and also when I tried editing any script file in the AppCore at all I get an error running the program such as this.

echo("hello world");
##/##/-----------------------------------------------------------------------------

.. (more stuff) ...

>>> Error report complete.

Wherever I put the echo I get those # 's.

Can anyone help me at all? I just want to do a blank hello world for now, nothing even fancy. I have written several c++ classes and functions I want to include in my project and see if I can load a level with them. But I cannot even begin to think about this, until I can at least get this issue figured out. :(


It causes the whole program to crash with bad access violations in several different source files.

#1
09/08/2014 (1:49 am)
Hello Matthew,

Have you looked through some of the documentation on the Github wiki? In particular, the Getting Started Guide and the GUI Intro do a decent job of explaining the module system and how to get your own scripts working.

The scripts for the truck example you mentioned can be found under modules/TruckToy. Basically the engine loads the AppCore module, AppCore loads the Sandbox module, and the Sandbox loads the truck toy module.

If you're still having issues, feel free to post some of your code here or with Github Gist, etc, and I'll be happy to help.
#2
09/08/2014 (2:09 am)
Thanks, I really appreciate the response. That answered my question on the truck example. I will try and read more in to the guide. I have read some of the Github wiki for Torque 2D but it seemed most of what I read was talking about how to actually write the scripts.

I will have to play around a little more, but do the .cs files have to be external or can they be included into the program and compiled into the project itself? ex: so no one can see or edit them basically?
#3
09/08/2014 (3:00 am)
Have a look at main.cs - it's the entry point to the engine and will show you where everything starts! Scripts can indeed be compiled into bytecode - someone more familiar with T2D specifically will have to tell you how!
#4
09/08/2014 (6:18 am)
What app are you using to create/edit scripts? Usually when you see #s in the console, there is some kind of syntax error. It can be related to whitespace or escape characters injected by editors.
#5
09/08/2014 (8:25 am)
I've been programming for more than 30 years and I will drop this one piece of advice - Always read all of the available documentation. When you're just picking up a game engine you are stepping into a large and unfamiliar codebase. When doing that it is very unwise to make assumptions - you need to learn how the designers intended things to be done so you can do them easily, or you'll be fighting every step of the way.

T2D and T3D are actually pretty fun to work in - I have used T3D to build a sound preview tool for work, took me less than 8 hours:
1) Make a UI
2) Add drag-n-drop to get sound filenames from a list box to text edits
3) Set up sound grouping so you could selectively play more than one sound at a time in up to four separate groups
4) Add multiple channel volumes for background music and effects
5) Set up the background music so that it would fade to a lower volume when effects were played and back to normal volume after
6) File browser to select a folder from which to load the sound file list
7) Inclusion of a base set of sounds playable from preset buttons
8) Background music start volume, play volume, exit volume sliders and "spinners" to adjust fade times for each transition
9) Background music "dip" volume slider and "spinner" to adjust fade times for in/out when effects are played

That's from memory - I'd have to look at it again to see if I missed anything. Anyway, the tool was to avoid the code/build/deploy cycle just to see if the background music was fading far enough during effect playback. You could just adjust and test on your desktop, note the values and then code them once.

TL:DR - Always read the docs, Torque is crazy powerful but you have to understand it before you can make it work for you.
#6
09/08/2014 (10:17 am)
Thanks everyone all this information really helps a lot.

Michael Perry, I am using xcode. Oddly enough when I tried to past it here it pasted a bunch of random characters instead of the qoutes.
#7
09/08/2014 (12:03 pm)
I do all of my developing on OSX. Since we can't use Torsion as our TorqueScript IDE, I've grown really fond of Sublime Text for all my script work. I even do a majority of C++ writing with it, only switching to Xcode for the code analyzer and obviously to compile the engine.

One thing regarding scripts - they remain as external files. But as Daniel hinted at, you can change the default setup to compile all scripts into .cs.dso files (bytecode), the only exception to that being the root main.cs script file.
#8
09/08/2014 (12:09 pm)
It should be pretty easy to get the engine to use a .dso for main.cs as well - but it's an engine-side mod and I think there was a thing about when the console system was actually available to decode the .dso....
#9
09/08/2014 (5:02 pm)
I write some code on my mac book pro (late 2013, 15in, osx 10.9.4). When making TorqueScript for Torque3D, I like to use Text Wrangler (free!). BBCode is also the option if you want to go the paid route... Those two editors are very powerful and support a lot of languages.

I've moved away from Torsion even when I develop on windows. I just use notepad++ now. There was no use for me using torsion, as I debug everything by hand and searching. (I don't use Torsion's debugger).

If you're interested in Text Wrangler or BBCode, here's the link to the developer's website.

http://www.barebones.com/products/textwrangler/