Game Development Community

Some file related problems & questions related to created a hexagon map and turn-based system using Torque.

by Richard Kindel · in Torque 3D Beginner · 01/17/2012 (2:09 pm) · 4 replies

Hello:

I�¢ï¿½ï¿½m trying to create a turn based strategy/RPG that uses a hexagon type old school grid for movement, ranging, and other purposes. I understand that I need to create a hexagon class in a separate script file, and I have some basic idea how to approach this based upon some other posts on the topic (such as offsetting grid rows and somehow making every other square �¢ï¿½ï¿½walkable�¢ï¿½ï¿½ and then overlaying a grid object somehow). What I need to know is exactly where should I position this file in the directory structure and what (other) file & where should I put the exec(�¢ï¿½ï¿½�¢ï¿½ï¿½) command in order to access the hexagon class to thus create a grid in 3d?

Assuming I have nothing other than the basic file structure of a newly created project (just the default stuff provided by torque) I have this on my NewProject3:

- Build files directory (containing 5 sub directories plus a compile.bat file)
- Game directory (containing 7 sub directories plus 7 other files including the main.cs script file)
- Source directory (contains 2 files)
- Web directory (contains 1 directory)
- Thumb.png plus ten other command and batch files

Most of these subdirectories have subdirectories of their own, in fact all of the game subdirectories contain a main.cs script file (I saw at least 5 of them). This is unbelievably confusing. Where on earth am I supposed to put the Hexagon class file? Where am I supposed to embed the exec() command in order to call the hexagon class (I�¢ï¿½ï¿½m assuming somewhere in the original main.cs file)?

I�¢ï¿½ï¿½ve been reading through these script files for two days now (although I don�¢ï¿½ï¿½t know torquescript fully, I have had courses in java and data structures in c++), and it�¢ï¿½ï¿½s just dizzying trying to figure out what calls what and where to start. I�¢ï¿½ï¿½m used to much smaller projects like we (generally) had for school assignments. The original main.cs in the �¢ï¿½ï¿½new project3�¢ï¿½ï¿½ directory (which I assume is the top-level main.cs file which runs the game-loop) seems to access the main.cs in the �¢ï¿½ï¿½game�¢ï¿½ï¿½ directory with the following command:

// The directory it is run from
$defaultGame = "scripts";

and there are a couple other exec(main.cs) in the loadDir and loadDirs function further down ... I purchased Torsion, so I�¢ï¿½ï¿½m reading these files using it.

The main.cs script file under the �¢ï¿½ï¿½scripts�¢ï¿½ï¿½ directory seems to be the main accessor (for a lack of better word) script, with the following lines:

exec( "./client/defaults.cs" );
exec( "./server/defaults.cs" );

Under the onStart() function, because these two scripts (client and server) in turn access a whole slew of other scripts from other subdirectories.

Basically, my approach at this point, in order to determine the correct positioning of my hexGrid script (which is still in-work) is to work backwards by figuring out which file the �¢ï¿½ï¿½squareSize�¢ï¿½ï¿½ (under scene tree, terrain inspector) gets modified and that�¢ï¿½ï¿½s probably the file I need insert my exec(hexGrid) function that I�¢ï¿½ï¿½m attempting to create. I can use a simple echo statement to verify once I figure out exactly where.

At this point, however, I have no idea which file I need to adjust (or where I need to create and insert a turn_Sequence script) in order to create a turn based game (which is my other problem).

Is there any tutorial or forum thread that goes a little in-depth on the file structure of new projects to help potential game designers figure out where we need to insert scripts (properly) and their needed exec() command (references) for proper file access? Or is there no other way than to just hack through every single line-by-line of script code in order to figure what needs to be modified and where (which sort of defeats the purpose of creating a game engine to make it �¢ï¿½ï¿½easier�¢ï¿½ï¿½ for new people to create their games). I don�¢ï¿½ï¿½t mind going the rock-busting, ball-busting route, it�¢ï¿½ï¿½s just going to take a whole lot longer to figure things out hacking through that path.

About the author

Recent Threads


#1
01/17/2012 (5:14 pm)
You seem to be having some issue with apostrophies - which aren't the thing on tilde, that's a "backtick" and doesn't translate well.

First up, read ALL the available stock documentation.
exec new files in either "datablockExec.cs" or "scriptExec.cs" - looking in there and you'll see all the files being exec'd.

Only directories under "game" are for game files, again read all documentation and doing some of the tutorials will help.

And as always, look at the examples.
#2
01/17/2012 (5:39 pm)
there are some thread on that.try to find by searching.
but now only can remember this:
http://www.garagegames.com/community/resources/view/21081


#3
01/17/2012 (9:05 pm)
I originally wrote this post in word (so I could spellcheck) since I knew it would be long, and then just copied & pasted into the forum post block when I was done. They were definitely apostrophies in word; I did not use the tilde key above the tab. How the forum post app (miss)translated word apostrophies .. I have no clue.

I've definitely been hacking my way through all the documentation ("hacking" is probably not the best verb to use in the context of a computer related theme though :) ). I've gone through about half the 3d core documents in the past couple weeks or so in my spare time, and I've downloaded the torquescript manual to my desktop, so I can read through it line-by-line once I finish the core documents. I've also been going through these forums and flagging some of the key tutorials. On top of that, I've purchased three torque guides on amazon (torque for teens by duggan, A game programmer's guide to torque by maurina, and 3D game programming all in one by finney). I'm almost done with the teens book, but it didn't provide much more than a basic overview, basically reinforced what I've read in the core docs (stuff like how to use the editors, the world editor, gui editor, etc).

@steve: I think you're the guy that is working on that blimp game design that I stumbled on a few days ago while perusing the forums, blogs, & tutorials if I'm not mistaken (your avatar looks familiar). It's mostly because of the hex grid artwork in your game & another guy's that I've really been inspired to hit the docs hard & lite a fire under my butt and figure out how to use torque, awesome work by the way.

@Ahsan: Thanks for the heads up with that post. It seems, apparantly, that it might be a good idea to sandwich those hefty initialization calls with some kind of exception handling mechanism .. so if one exec() doesn't work it'll at least throw up some kind of flag. I know java has a good try catch statement which I've used once or twice, I don't know enough about torquescript (yet) to know if it has something similar but I hope it does.

Apparently, there's just no way to get around the frontal assault: just going to have read everything I can and work through the tutorials however long it takes.

BTW: I'm really not interested in FPS shooters (I'm just not into hand eye games, I much prefer games of skill). I'm one of those old school grognards going back to the Avalon Hill boardgame days. I love hex based strategy, RPGs, card games, etc. My favorite computer games are MOO2, Imperialism I and II ('92), Sid Meir's civilization and colonizaiton, Anno 1702 .. more recent games: Dominions III, Distant worlds, Europa Universalis .. so my blueprint designs that I've etched out so far all center around either hex or area movement systems and are mostly turn based. By the way, can't leave out the greatest game ever made (even if it is a boardgame) ... ASL :)
#4
01/18/2012 (6:59 am)
Ah, the hexgrid which I'm using in the blimp thing is made of standard TsStatic shapes rather than a specific class.

Regardless of your genre tastes there are plenty of useful pointers for using the engine in the FPS tutorial, but there is also a mini RTS style tut in the documentation and I wrote a couple of mini tutorials in the resources section. There's a turnbased tactical/action hybrid tutorial in there.