LoadMission
by gamer · in Torque Game Engine · 06/01/2006 (6:46 pm) · 3 replies
When loading a mission there's a few lines of code as follows:
I looked for the function setConnectArgs, setJoinPassword, connectLocal everywhere in the scripts under common and mygame, can't find them. why? are they defined in the c++ engine only?
the reason I am asking is that I found two ways of loading a mission, the first one is calling loadMission:
the second one is
I am guessing that the first one is from the server and the second way is from the client. So if I want to be able to click on the button to load a mission file, should I use the second one instead of the first one? I am guess that connectLocal from client will eventually make the server call loadMission(), is this right?
thanks
%conn = new GameConnection(ServerConnection); RootGroup.add(ServerConnection); %conn.setConnectArgs($pref::Player::Name, $pref::Player::Armor); %conn.setJoinPassword($Client::Password); %conn.connectLocal();
I looked for the function setConnectArgs, setJoinPassword, connectLocal everywhere in the scripts under common and mygame, can't find them. why? are they defined in the c++ engine only?
the reason I am asking is that I found two ways of loading a mission, the first one is calling loadMission:
function loadMission( %missionName, %isFirstMission )
{
error("MissionName is "@%missionName);
endMission();
echo("*** LOADING MISSION: " @ %missionName);
echo("*** Stage 1 load");
echo("serverGroup is "@ServerGroup);
// Reset all of these
clearCenterPrintAll();
clearBottomPrintAll();
// increment the mission sequence (used for ghost sequencing)
$missionSequence++;
$missionRunning = false;
$Server::MissionFile = %missionName;
// Extract mission info from the mission file,
// including the display name and stuff to send
// to the client.
buildLoadInfo( %missionName );
// Download mission info to the clients
%count = ClientGroup.getCount();
for( %cl = 0; %cl < %count; %cl++ ) {
%client = ClientGroup.getObject( %cl );
if (!%client.isAIControlled())
sendLoadInfoToClient(%client);
}
// if this isn't the first mission, allow some time for the server
// to transmit information to the clients:
if( %isFirstMission || $Server::ServerType $= "SinglePlayer" )
loadMissionStage2();
else
schedule( $MissionLoadPause, ServerGroup, loadMissionStage2 );
}the second one is
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);
%conn = new GameConnection(ServerConnection);
RootGroup.add(ServerConnection);
echo("playerName is " @ $pref::Player::Name@",player armor is "@ $pref::Player::Armor);
%conn.setConnectArgs($pref::Player::Name, $pref::Player::Armor);
%conn.setJoinPassword($Client::Password);
%conn.connectLocal();
}I am guessing that the first one is from the server and the second way is from the client. So if I want to be able to click on the button to load a mission file, should I use the second one instead of the first one? I am guess that connectLocal from client will eventually make the server call loadMission(), is this right?
thanks
About the author
#2
06/01/2006 (7:05 pm)
Thank you that is defnitely a good resource!
#3
In general, you always need to search in both the script code and the c++ code when looking for a specific implementation of a referenced function or method.
06/02/2006 (8:53 am)
The reason that you didn't find those functions defined in script is because they are actually ConsoleFunctions, which, as you surmised, are implemented in c++.In general, you always need to search in both the script code and the c++ code when looking for a specific implementation of a referenced function or method.
Torque Owner Juan Aramburu
http://tdn.garagegames.com/wiki/Torque_Console_Objects
I run a search over at tdn.garagegames.com and usually look for pages that start with "Torque Console Objects...".