Game Development Community

Starting from Empty template

by GuS · in Torque 3D Beginner · 03/10/2013 (1:27 am) · 7 replies

Hi dudes,
I'm new to Torgue, but TorqueScript seems quite comprensible for me (I'm a web programmer).
I've followed the RTS-camera tutorial in the docs and I found it really cool.
So, i've created an empty project, trying to create this "simple" behaviour:

1- Enter the game
2- Press Play and load my level (skipping the ChooseLevelDlg GUI)
3- Entering the mission spawing a "player" with and orbit camera (RPG style)
4- move the the camera around the player using arrows

As you could understand it would be a simple test for a "character creation scene".

Ok, the problem is point 3: I'm entering the mission but I can't create a player and an orbit camera from scretch.

I really can't well undestand the logic behind the client-server connection and game init.
Someone can address me to the right path?
Thx!

PS: are there any docs out there that can explain me the logics of file structure in empty template? What file makes what...what function make whats...etc... Only to start undestanding all logics.

About the author

Recent Threads

  • CH5] A Pickup issue?

  • #1
    03/10/2013 (6:15 am)
    This isn't really an answer to your question, but Michael Hall is working right now on a big restructuring of the default template scripts to hopefully make all that stuff a lot more explicable. I'd wait until he's done with that and work with the new template! It'll be easier, I think!
    #2
    03/10/2013 (11:17 am)
    Thx Daniel for your answer. I'll be waiting for Michael's restructuring.
    Meanwhile, where can I find the function that adds the player in the game?
    The FPS template is to complex to understand "step-by-step", so I'd like to understand where can I put some code to add the player in the Empty template project....and maybe what should I write :)

    However, which scripts are loaded first?
    I'm starting from "game/main.cs", but I can't understand when and where client/server scripts are called...
    Any suggestion?
    #3
    03/10/2013 (12:47 pm)
    Look for the exec() calls and trace your way through that way. It would really be worth your while to buy Torsion - you can actually jump to function definitions using it.
    #4
    03/10/2013 (1:05 pm)
    Richard, this could be a great idea. If Torsion can easily make me go through definitions, maybe it'll be my next buy.

    Now I've found a tutorial made by Lukas Peter Joergensen (github.com/lukaspj/Torque3D-Tutorials/tree/master/Tutorials) and it's really great for a noob like me.








    #5
    03/10/2013 (1:26 pm)
    From the rool level main.cs the game directory get's executed (as well as tools). In T3D this is "scripts". From the scripts/main.cs the core scripts are immediately loaded. It is the core that is responsible for loading (in theory) the client (and server) methods that are necessary for Torque to function. For the most part you don't need to deal with the core, so back to scripts.

    Your "game" scripts are all located under /scripts. These are separated by server and client specific scripts. The server is responsible for all of your gameplay logic, item and object interaction methods, etc. The main.cs located in /scripts -- the one that kicked off the core -- has a script package called "fps" or some such. Inside of this package are some basic functions that all mods/modules can use/override/extend. The server and client directorys have a separate "init.cs" (exec'd within onStart()) that in turn loads the basic client and server game scripts.

    In both the Full and Empty Templates there is a "scriptExec.cs" located under ./server. This is where you add the exec command for additional scripts that you want to add. It is here that the bulk of the difference between Full and Empty reside. Datablocks also have a similar datablockExec.cs, and is where the bulk of the difference between the two templates lies in regards to datablocks.

    To add a player to the Empty Template. You need a PlayerData datablock, and you need some script methods -- you can refer to the Full Template (both files (datablock and script) are called player.cs) for details as to what these contain. Note however that the script methods can be reduced to a more minimal amount of functionality -- an easy exercise for someone with more intermediate experience with Torque.

    Once you have these two things setup you need to go into game.cs (scripts/server) and find the global variables that dictate the default spawn object. In the Empty Template this is an empty string, which causes the spawn method to spawn a camera.

    Change:
    $Game::DefaultPlayerClass = "";
    $Game::DefaultPlayerDataBlock = "";
    $Game::DefaultPlayerSpawnGroups = "CameraSpawnPoints PlayerSpawnPoints PlayerDropPoints";
    To:
    $Game::DefaultPlayerClass = "Player";
       $Game::DefaultPlayerDataBlock = "DefaultPlayerData";
       $Game::DefaultPlayerSpawnGroups = "PlayerSpawnPoints";
    You'll have to check but I think the Empty Template uses the same default.bind.cs (scripts/client) as the Full Template -- if not you'll need to define some movement keys for the player. The rest of adding the player is by placing an appropriately named missiongroup with spawn markers that point to your player datablock -- and I'm pretty sure that the documentation covers that.

    And that's a rough outline to script execution order and a loose guide for how to add a player to the Empty Template.

    #6
    03/10/2013 (1:30 pm)
    Quote:
    but Michael Hall is working right now on a big restructuring of the default template scripts to hopefully make all that stuff a lot more explicable. I'd wait until he's done with that and work with the new template! It'll be easier
    I hope it will be easier! Unfortunately, due to some new goals and redesigned outline, the full restructuring effort probably wont make it into the next release as originally planned. However, some of the cleanup that occurred during the restructuring passes will most likely make it through in time.
    #7
    03/10/2013 (1:38 pm)
    Simply amazing! Thank you Michael, I'll be working on your suggestions.