Missing things in the TGEA 1.7 Template Scripts...?
by Gareth Hewes · in Torque Game Engine · 10/17/2008 (10:42 am) · 6 replies
I've been getting better with the TGEA ins and outs, but I have noticed a few strange things. What makes it stranger is that I wouldn't think the engine could function as it does without these, so I assume they are somewhere in the scripts, but I can't find them.
First of all is the Load Mission function. I did a search and found some stuff (gotta love Torsion, makes life so much easier), but surprisingly no calls as to where in script the 'Start Game' button on the main menu is linked to the function that actually loads the mission. I thought this should be in the script for the main menu GUI, but the block that controls the 'Start Game' button is blank. First of all, does anyone know where the mission is loaded from at that point? This is essential if I want to mess around with my own GUIs. Second, how is the button linked to that function if it is not defined in the code block for the button itself? That just seems crazy to me.
The other problem I have is that I was trying to delete pretty much everything in the mission and have the player spawn inside an interior I made. The problem I came across is that the player has no defined spawn point in the Template. I looked inside the SimGroup of PlayerSpawnPoints, but there was nothing there. When I tried to find a spawnpoint in the Mission Creator view, I couldn't find it anywhere (isn't it usually in the Mission objects menu? I could have sworn it was). So how does the player know to spawn there in the Template without a spawn point, and how can I create a player spawn point inside the interior?
Any elaboration on either of these points would be much appreciated. It seems like this stuff should be very straightforward, but nothing is where I expect it to be.
Thanks in advance for any help!
First of all is the Load Mission function. I did a search and found some stuff (gotta love Torsion, makes life so much easier), but surprisingly no calls as to where in script the 'Start Game' button on the main menu is linked to the function that actually loads the mission. I thought this should be in the script for the main menu GUI, but the block that controls the 'Start Game' button is blank. First of all, does anyone know where the mission is loaded from at that point? This is essential if I want to mess around with my own GUIs. Second, how is the button linked to that function if it is not defined in the code block for the button itself? That just seems crazy to me.
The other problem I have is that I was trying to delete pretty much everything in the mission and have the player spawn inside an interior I made. The problem I came across is that the player has no defined spawn point in the Template. I looked inside the SimGroup of PlayerSpawnPoints, but there was nothing there. When I tried to find a spawnpoint in the Mission Creator view, I couldn't find it anywhere (isn't it usually in the Mission objects menu? I could have sworn it was). So how does the player know to spawn there in the Template without a spawn point, and how can I create a player spawn point inside the interior?
Any elaboration on either of these points would be much appreciated. It seems like this stuff should be very straightforward, but nothing is where I expect it to be.
Thanks in advance for any help!
#2
This makes sense to me, but I don't have the stuff in front of me, so I'll have to wait until I get home until I try it out. Thanks for the clarification!
Any ideas on the spawn point issues?
10/17/2008 (12:19 pm)
Hmm...(rubs chin and nods head, feigning complete comprehension)This makes sense to me, but I don't have the stuff in front of me, so I'll have to wait until I get home until I try it out. Thanks for the clarification!
Any ideas on the spawn point issues?
#3
Personally I don't use the template but have my own way of doing things.
I don't use Torsion either but surely it has a Find-In-Files feature? My text editor does.
So far as I can remember about SpawnPoints is that they have always been found under the Shapes category in the WorldEditor: Shapes -> Misc -> PlayerSpawnPoint. They are created in the PlayerDropPoints simGroup as an object called SpawnSphere. And if you take a look in server/scripts/game.cs at pickSpawnPoint() you'll see that if a spawn point is not found then it defaults to dropping the player at position/rotation "0 0 300 1 0 0 0" the center of the world.
10/17/2008 (12:22 pm)
The Template uses the "unifiedShell" gui stuff that is found in the Common directory, which is a bit convoluted I admit. It utilizes a totally different GUI setup than the example games do. The Start Game button has a command attached to it called "onSinglePlayer()" Which is function onSinglePlayer() found there in the MainMenuGui.cs but is over-ridden in ShellGui.cs in the game's ScriptsAndAssets/client/scripts directory. From there function onSinglePlayer() calls loadDefaultMission() which is also found in the ScriptsAndAssets/client/scripts directory. function loadDefaultMission() is what loads the relevant mission.Personally I don't use the template but have my own way of doing things.
I don't use Torsion either but surely it has a Find-In-Files feature? My text editor does.
So far as I can remember about SpawnPoints is that they have always been found under the Shapes category in the WorldEditor: Shapes -> Misc -> PlayerSpawnPoint. They are created in the PlayerDropPoints simGroup as an object called SpawnSphere. And if you take a look in server/scripts/game.cs at pickSpawnPoint() you'll see that if a spawn point is not found then it defaults to dropping the player at position/rotation "0 0 300 1 0 0 0" the center of the world.
#4
And if I define a spawnSphere, it will automatically drop my player there, right? I would ask about multiple ones (for multiplayer games), but I'm still quite a ways away from implementing that.
Gah! I wish I was at home!
10/17/2008 (12:48 pm)
(Slaps head) Ugh, I didn't even think to check the shapes directory...for some reason I had it in my head that it was in the System/Mission objects area.And if I define a spawnSphere, it will automatically drop my player there, right? I would ask about multiple ones (for multiplayer games), but I'm still quite a ways away from implementing that.
Gah! I wish I was at home!
#5
10/17/2008 (12:59 pm)
Oops - I use the AFX version, and forgot completely about the fact that it's different than the plain vanilla TGEA template. Sorry!
#6
With the default code yes, you will spawn at that point. With the default code, if you create multiple spawn points, the code will randomly choose one. For the default code to work, all of your spawn points need to be in a sim group named PlayerDropPoints.
Look at the pickSpawnPoint method in the game.cs file inside scriptsAndAssets\server\scripts.
10/17/2008 (1:05 pm)
Quote:
And if I define a spawnSphere, it will automatically drop my player there, right? I would ask about multiple ones (for multiplayer games), but I'm still quite a ways away from implementing that.
With the default code yes, you will spawn at that point. With the default code, if you create multiple spawn points, the code will randomly choose one. For the default code to work, all of your spawn points need to be in a sim group named PlayerDropPoints.
Look at the pickSpawnPoint method in the game.cs file inside scriptsAndAssets\server\scripts.
Associate Jaimi McEntire
King of Flapjacks
function LoadMission(%MissionFile, %PlayerName)
{
createServer("SinglePlayer", %MissionFile);
%conn = new GameConnection(ServerConnection);
RootGroup.add(ServerConnection);
%conn.setConnectArgs(%PlayerName);
%conn.setJoinPassword($Client::Password);
%conn.connectLocal();
}
The function is called from the "Launch Mission" button:
new GuiButtonCtrl() {
profile = "GuiButtonProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "342 271";
extent = "105 23";
minExtent = "8 8";
visible = "1";
command = "SM_StartMission();";
text = "Launch Mission";
groupNum = "-1";
buttonType = "PushButton";
helpTag = "0";
};
If you're asking how the StartMissionGui is created, here is the button to "Start Mission...":
new GuiButtonCtrl() {
canSaveDynamicFields = "0";
Enabled = "1";
isContainer = "0";
Profile = "GuiButtonProfile";
HorizSizing = "right";
VertSizing = "top";
position = "614 88";
Extent = "110 20";
MinExtent = "8 8";
canSave = "1";
Visible = "0";
Command = "Canvas.setContent(startMissionGui);";
hovertime = "1000";
text = "Start Mission...";
groupNum = "-1";
buttonType = "PushButton";
useMouseEvents = "0";
};
The Command value on this button sets the startMissionGui as the current Gui.