Jump to content
Smart Games

Configure Spawn-Locations in Config-File?

Recommended Posts

Hello all,
I am currently working on a Ui in which you can select a spawn location from a list box and then be teleported there. 

I imagine to store the locations in something of the following type in a config file, but I have no idea how to do it:

 

class JF_Locations {
	class Devils_Mountain {
		name = "Devil's Mountain";
		id = 001;
		air = true;  //is it allowed to spawn via airdop 
		land = true; //is it allowed to spawn on the ground
		water = false; //is it allowed to spawn on the water
		coordinates = [100, 100, 0];
		description = "blablabla";
	};

	class Under_Water_Palace {
		name = "Under Water Palace ";
		id = 002;
		air = false;  //is it allowed to spawn via airdop 
		land = false; //is it allowed to spawn on the ground
		water = true; //is it allowed to spawn on the water
		coordinates = [50, 250, 0];
		description = "blablabla";
	};
};

 

If it's possible, how do I read the locations from the config file and turn them into an array or something?

Is there a better way? I like this clean format.

 

Thank in advance,

Jacob

Share this post


Link to post
Share on other sites

 

I m a noob at config scripting but I guess the syntax for arrays is like this (copied out of a config.cpp):

		// When any of the addons is missing, pop-up warning will appear when launching the game.
		requiredAddons[]={"cba_settings"};

in scripts you can get those arrays with

getArray

 

but I could be absolutly wrong here cause I know nothing bout UIs and only a little bit of configs...

  • Thanks 1

Share this post


Link to post
Share on other sites
5 hours ago, Smart Games said:

If it's possible, how do I read the locations from the config file and turn them into an array or something?

Perhaps @Larrow post can help you here.  See bottom section.

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Configs are good for storing this type of data

 

example:
 

_locations = missionConfigFile >> "JF_Locations";

for "_i" from 0 to (count _locations - 1) do
{
_loc = _locations select _i;

systemchat format["Location: %1", getText (_loc >> "name") ];

};

 

(Code not tested)

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×