Replace Start Button in FPS starter
by Samarie · in Torque Game Engine · 07/29/2009 (8:37 am) · 6 replies
I'm trying to apply what I learned in the Getting Started tutorial to the FPS Starter kit. For example,
I tried creating a new "start button" in the FPS Starter kit, but it doesn't take me to my mission file "demo.mis" when I click on it. It works fine when I try it in tutorial.base. I added the line loadMyMission(); in the command field of the Gui Editor like it said in the Getting Started tutorial but it doesn't work in the fps starter kit.
I noticed in the tutorial.base folder, the function loadMyMission(); is located in main.cs, but in the FPS Starter Kit it isn't set up like that. I tried copying and pasting that function from main.cs in tutorial.base to the FPS Starter kit and it doesn't work. So, where should I place the function loadMyMission() in the FPS Starter kit so when I click my new "Start Button" it takes me directly to my mission file or do I need to do something entirely different?
I just want to delete the "Start Mission" button in the FPS Starter kit and replace it with a simple one, where you just click and it takes you right into the game like the "Start Button" in the Getting Started Tutorial.
Thanks,
I tried creating a new "start button" in the FPS Starter kit, but it doesn't take me to my mission file "demo.mis" when I click on it. It works fine when I try it in tutorial.base. I added the line loadMyMission(); in the command field of the Gui Editor like it said in the Getting Started tutorial but it doesn't work in the fps starter kit.
I noticed in the tutorial.base folder, the function loadMyMission(); is located in main.cs, but in the FPS Starter Kit it isn't set up like that. I tried copying and pasting that function from main.cs in tutorial.base to the FPS Starter kit and it doesn't work. So, where should I place the function loadMyMission() in the FPS Starter kit so when I click my new "Start Button" it takes me directly to my mission file or do I need to do something entirely different?
I just want to delete the "Start Mission" button in the FPS Starter kit and replace it with a simple one, where you just click and it takes you right into the game like the "Start Button" in the Getting Started Tutorial.
Thanks,
About the author
I'm an undergraduate student studying game and simulation programming at a university.
#2
Take a look at the default "Start" button in the mainMenuGui.gui file you will find this line:
Following on, if you look at startMissionGui.gui you will see that the "Start Mission!" button has this command
It is SM_StartMission() that you want your "new" button to point to if you don't wish to use the startMissionGui.gui. There is no need to add anything from tutorial.base into the starter.fps.
07/29/2009 (11:26 am)
The starter.fps does not use "startMyMission" from the tutorial.base project, nor do you really want to.Take a look at the default "Start" button in the mainMenuGui.gui file you will find this line:
command = "Canvas.setContent(startMissionGui);";That causes the startMissionGui to appear instead of jumping directly to a mission.
Following on, if you look at startMissionGui.gui you will see that the "Start Mission!" button has this command
command = "SM_StartMission();";This points to function function SM_StartMission() which kicks off the mission load.
It is SM_StartMission() that you want your "new" button to point to if you don't wish to use the startMissionGui.gui. There is no need to add anything from tutorial.base into the starter.fps.
#3
07/29/2009 (1:38 pm)
I created a start button and pointed it to SM_StartMission(); in the Gui Editor command. When you click it, it says waiting for server and nothing happens.
#4
07/29/2009 (5:10 pm)
Do you have in some place the function Sm_StartMission(); some cases, when the server is waiting for, is for the reason we have some mistake in the script, in the console do you have some error?
#5
Take a look at the first couple of lines in SM_StartMission()
Since you are bypassing the startMissionGui then you must tell it what mission to start. Here's a simple little rewrite of SM_StartMission()
07/29/2009 (7:00 pm)
Did you give it a mission to open?Take a look at the first couple of lines in SM_StartMission()
%id = SM_missionList.getSelectedId(); %mission = getField(SM_missionList.getRowTextById(%id), 1);What the gui does is populate a list of missions for the gui to display. Default behavior is then to let the player select a mission and it goes from there.
Since you are bypassing the startMissionGui then you must tell it what mission to start. Here's a simple little rewrite of SM_StartMission()
function SM_StartMission()
{
//%id = SM_missionList.getSelectedId();
//%mission = getField(SM_missionList.getRowTextById(%id), 1);
if ($pref::HostMultiPlayer)
%serverType = "MultiPlayer";
else
%serverType = "SinglePlayer";
//createServer(%serverType, %mission);
createServer(%serverType, "game/data/missions/yourLevel.mis"):
%conn = new GameConnection(ServerConnection);
RootGroup.add(ServerConnection);
%conn.setConnectArgs($pref::Player::Name);
%conn.setJoinPassword($Client::Password);
%conn.connectLocal();
}Notice the lines that I commented out since you're bypassing the functionality of the startMissionGui. If you know already that your game is not going to be multiplayer then you can simply create a "SinglePlayer" server. Make sure that you change the path in the new createServer() line to reflect the path and filename of the level you wish to load.
#6
07/30/2009 (1:09 pm)
I really appreciate how you explained it. Thank you for your help. It's working now. Thanks. I also had to delete the function startMissionGui::onWake() for it to work.
Torque 3D Owner ERICK MIRANDA M