Game Development Community

MissionGroup; how to access?

by Jovani Adolfo · in Torque 3D Professional · 06/04/2012 (8:00 am) · 14 replies

Hello, I would like to know how to access the missiongroup simGroup, how do you do this?

#1
06/04/2012 (8:37 am)
To add something to MissionGroup:
%myObj = "your_thing";
MissionGroup.add(%myObj);

Also check out the chm file in the documentation folder (you'll need to right-click and select "unblock" to get it to work) there's lots of useful information on scripting in there.
#2
06/04/2012 (11:30 am)
I meant like to access and change the permanent name of an object in the MissionGroup.
#3
06/04/2012 (12:23 pm)
Call the name or ID of the object you want to rename and then give it a new name.
%name/id.setName("NewName");
#4
06/04/2012 (6:56 pm)
WHat about mission cleanup?
#5
06/05/2012 (4:29 am)
Access things directly with the object's name/ID if you're not adding or removing from a SimGroup.

SimGroups are for keeping things tidy, "missionCleanUp" is to make sure that everything gets deleted when a mission ends. You can also iterate through a simGroup by using:

%set = "missionCleanup";
foreach(%obj in %set)
{
   echo(%obj.getID() SPC %obj.getName() SPC %obj.getClassName());
}

That will echo in the console ever object inside missionCleanUp and print it's ID, name (if it has one or a blank space if it does not) and it's classname.
#6
06/05/2012 (11:34 am)
How would you change the permanent name of the client OBJECT. Not the player name like in an MMO, but like the name of the object because:

example 1. If you first enter a new game (game begins) the name is not there and I have to manually change the name of the player object by selecting it in the world editor, then changing it in the "name" field.

example 2. The reason is because I am making it switch datablocks.

example: MyObject.setDatablock(MyDatablock);
cannot find object "MyObject" attempting to call function "setDatablock"
then I have to repeat example 1.
#7
06/05/2012 (11:46 am)
Have a look in the Torque Script chm for the connection commands regarding returning the client. Then get the client control object for the playerObject under control.

Equally you could call %player.getControllingClient(); on spawning the player.
#8
06/05/2012 (11:50 am)
Also you can just loop through the clientgroup as a simGroup. Search the stock scripts for "clientGroup".
#9
06/06/2012 (11:21 am)
would this work?

player.cs

I added the following lines to player.cs:

//------------------------------------------------------------------------------------
//Power Up and player select.
//------------------------------------------------------------------------------------

%client.characterchosen = "None";
}
If (%client.characterchosen == "None");
{
%client.characterchosen = "Awaiting";
}
If (%client.characterchosen == "1";
{
%client.player.setDatablock(DefaultPlayerData);
}
else
{
%client.player.setDatablock(OtherData);
}
#10
06/06/2012 (1:09 pm)
[quote]
I added the following lines to player.cs:[quote]

Player.cs is kind of a big thing ...

If you're spawning the playerObject you can have the client decide which datablock they want and then pass that along when the spawn function is called.

//note this is just as way of explanation.
   %player = new Player()
   {
      dataBlock = %use_this_datablock;
   };
   MissionCleanup.add(%player);

I'd suggest looking in gameCore.cs for how it's done in the stock scripts, especially spawnPlayer function, and also in spawn.cs which is somewhere inside the "core" folder.

%player = spawnObject($Game::DefaultPlayerClass, $Game::DefaultPlayerDataBlock);
#11
07/02/2012 (12:11 pm)
Thanks Steve!

I didn't really use it, but it will probably be very useful :D
#12
07/02/2012 (12:16 pm)
That's okay. :)
#13
07/02/2012 (12:19 pm)
Can I make a button with this command?

$Game::DefaultPlayerDataBlock = "DefaultPlayerData";

$Game::DefaultPlayerDataBlock = "OtherPlayerData";
#14
07/03/2012 (5:40 pm)
Quote:Can I make a button with this command?
yes.
in buton's command property paste
$Game::DefaultPlayerDataBlock = "DefaultPlayerData";