Jump to content
Sign in to follow this  
Mike84

A better way of dealing with parameters

Recommended Posts

Usually when dealing with parameters you need to always check at which index the parameter is before you can get the value. Because this is such a cumbersome method, I decided to make a script that would not require indices anymore, and instead get the code that belongs to the parameter from inside the parameter class (where it should've been imho).

It is very easy to make your parameters compatible with my processParamsArray script so you never have to bother about indices ever again.

The only thing you have to do, besides from copying my script to your folder, is to put a code value in your parameter classes, like so:

class ViewDistance // 0
{	
title = "View Distance:";
values[] = { 1200, 1500, 2000, 2500, 3000 };
texts[] = { "1.2 km", "1.5 km", "2 km", "2.5 km", "3km" };
default = 2000;
code = "setViewDistance %1";
};

As you can see in this example the code value here is setViewDistance %1, but what does the %1 stand for? If you are not familiar with the format command, it stands for a placeholder that will be replaced with an actual value later on, in this case a value from the parameters value array (values[]).

So assuming that the player doesnt change the default setting for this parameter, the value for this parameter will become 2000 because that's what the default is set too. The script then gets this value and replaces the %1 with the param value, so you'll end up with something like this: setViewDistance 2000.

After the script replaced %1 with the appropriate value, it then compiles and executes the code.

That's it really, look for more examples in the description.ext

Get the example mission and more information here.

Edited by Mike84

Share this post


Link to post
Share on other sites

Question About Params?

How do i get this to work.. It origonaly looked like this:

BIS_playtime = (param1 * 60);

and i want it with the new setup something like this but it doesnt work.. :/

BIS_playtime = ((paramsArray select 5) * 60);

Share this post


Link to post
Share on other sites

Sure it does, just not in Single Player Editor Preview, as paramsarray is an empty array in there.

Share this post


Link to post
Share on other sites

hmm yeah im testing in the MP Editor.. hmm gona play around with it a lil more maybe my script is bad, ah got it working!!

Edited by MattXR

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
Sign in to follow this  

×