Game Development Community

mission files - possible to load variables from it ?

by Jeff Yaskus · in Torque Game Engine · 02/23/2010 (12:52 pm) · 4 replies

I'm still learning the ins and outs of TGE ... trying to design operations that happen on mission loading.

1) I'd like to store a minimum and maximum elevation variable within my mission file.

So when the mission loads, I can randomly add rocks and trees between elevations of these values.
(they can't be contained within the mission file themselves as they are "resources" to be harvested and not static objects)

2) Create a data block (or reference an existing DB) ... so I can change the music when the module loads.

That way, I can have music for the MENU gui ... and when you select a given mission,it starts its own music.

--

Can anyone point me to some examples of how this might be done?

#1
02/23/2010 (1:09 pm)
The default mission in the RTS kit has team names ... but I don't see where its loaded or how to access these. But it suggests its "possible" to load variables from the mission files.

new ScriptObject(MissionInfo) {
         desc0 = "This mission provides a simple set-up where you can play around with the features of the RTS Starter Kit.  You can select units, run them around, play with the camera, and get a feel for how the pack works.";
         team0 = "Aces";
         team1 = "Skulls";
         team2 = "Ponies";
         team3 = "Rawr!";
         name = "Example Mission";
   };
#2
02/23/2010 (1:34 pm)
you can access any variable you put in the missionInfo block easily.
it is as simple as writing in your scripts "MissionInfo.yourvariable". I wish I could give a better explanation but I am in a hurry...hope that helps!
#3
02/23/2010 (10:11 pm)
Quote:(they can't be contained within the mission file themselves as they are "resources" to be harvested and not static objects)
Just to be clear, you can save dynamic objects in the mission itself - you just can't do that if you want, for example, random placement of resources each time the mission loads.
#4
02/24/2010 (12:52 am)
Thanks guys ! I added (2) fields under the missionInfo {} in the mission file ... set the variables to 118 and 130. The global.cs has it defined as 0 and 80

and my echo test shows the values 118 and 130 -- that works great - amazing!

// JY - test to see if I can read it from the mission file
 %treeMin = MissionInfo.treeline;
 %rockMin = MissionInfo.rockline;
 if (%treeMin $= "")
    %treeMin = $Game::TreeLine; // default if not found in mission file
 if (%rockMin $= "")
    %rockMin = $Game::RockLine; // default if not found in mission file         
 echo("seedResource: treeMin=" SPC %treeMin SPC ",rockMin=" SPC %rockMin);