Jump to content
Sign in to follow this  
zodd

Config.cpp Logic classes - How do you add in editor amendable variables?

Recommended Posts

Gday all,

I have made the exciting jump from creating collections of scripts to actually packaging them up as a mod! Great times!

I am trying to make it flexible - there are 4 components that may or may not be initialised, depending on what the mission designer wants. This works great with scripts because you can specify the init values in the init.sqf... packaging as a mod makes this a little more complicated! Unfortunately a lot of the tutorial content seems to be based around getting units/models into the game as opposed to purely script based mods...

Extract from Config.cpp

class cfgVehicles
{
class Logic ;
class ZodNavDebugOn : Logic
{
	displayName = "Enable ZOD init debug";
	vehicleClass = "Modules";
	class Eventhandlers {
		init = "_ok = _this execVM '\NavAids\debugOn.sqf'";
	};
};
class ZodNavStartAll : Logic
{
	displayName = "Use all ZOD_NAV modules";
	vehicleClass = "Modules";
	class Eventhandlers {
		init = "_ok = [true, true, true, true] execVM '\NavAids\initNavAids.sqf'";
	};
};
};

The ZodNavStartAll class is the one I want to change - As you can see from the init, it is passing 4 booleans to the initNavAids.sqf

The workaround I could use is have an init module (if no values are passed it will default to true) and have 4 placeable modules but what I would prefer is to have a way to place the module, then edit the individual variables...

eg. something like:

class ZodNavStartAll : Logic
{
	displayName = "Use all ZOD_NAV modules";
	vehicleClass = "Modules";
               //eg something like:
               // class Variables{
                // var = [_initMod1, _initMod2, _initMod3, _initMod4];
               //Default values
               //Checkbox or other way to display and edit the variables in the module inside the editor (eg like when placing waypoints, there is a drop down box for type, speed etc)
               // };
	class Eventhandlers {
		init = "_ok = [_initMod1, _initMod2, _initMod3, _initMod4] execVM '\NavAids\initNavAids.sqf'";
	};
};

I have seen mods that do this but not sure how to go about it (I have tried:

http://community.bistudio.com/wiki/Category:ArmA:_Addon_Configuration

http://forums.bistudio.com/showthread.php?130062-The-Configs-amp-Scripting-Info-Thread-%28WIP%29

http://community.bistudio.com/wiki/CfgVehicles_Config_Reference

And google searches of everything I can think of...)

Any pointers would be GREATLY appreciated!

Share this post


Link to post
Share on other sites

Read about Arma 3 Module Framework

Then build on example below.

ZOD_NAV/modules/config.cpp

class CfgPatches
{
class ZOD_NAV_Module
{
	requiredaddons[] = {"A3_Modules_F"};
	requiredversion = 0.1;
	units[] = {"ZOD_ModuleNavStartAll"};
};
};

class CfgFunctions
{
class ZOD_Modules
{
	tag = "ZOD";
	class Nav
	{
		file = "ZOD_NAV\modules\functions";
		class moduleNavStartAll {}; // will compile fn_moduleNavStartAll.sqf into ZOD_fnc_moduleNavStartAll function.
                       // class foo {}; // i.e. fn_foo.sqf -> ZOD_fnc_foo
                       // class bar {}; // i.e. fn_bar.sqf -> ZOD_fnc_bar
	};
};
};

class CfgFactionClasses
{
class NO_CATEGORY;
class ZOD: NO_CATEGORY
{
	displayName = "Zod";
};
};

class CfgVehicles 
{
class Logic;
class Module_F: Logic
{
	class ArgumentsBaseUnits
	{
		class Units;
	};
	class ModuleDescription;
};

class ZOD_ModuleNavStartAll : Module_F
{
	scope = 2;
	displayName = "Use all ZOD_NAV modules";
	category = "ZOD";
	author = "Zodd";
	function = "ZOD_fnc_moduleNavStartAll"; // function to call when module is initialized
	isGlobal = 0;
	isPersistent = 0;
	isTriggerActivated = 0;
	class Arguments: ArgumentsBaseUnits
	{
		class Units: Units {};
		class Debug
 			{
			displayName = "Debug";
			description = "Enable debugging"; 
			typeName = "BOOL";
			class values
			{
				class Yes
				{
					name = "$STR_lib_info_yes";
					value = 1;
					default = 0;
				};
				class No
				{
					name = "$STR_lib_info_no";
					value = 0;
					default = 1;
				};
			};
		};
		class MyModuleParam1
 			{
			displayName = "my param 1";
			description = "my param 1 description"; 
			typeName = "NUMBER";
			defaultValue = 0.1;
		};
		class MyModuleParam2
 			{
			displayName = "my param 2";
			description = "my param 2 description";
			typeName = "STRING"; // default
			defaultValue = "hello, world!";
		};
	};
};
};

ZOD_NAV/modules/functions/fn_moduleNavStartAll.sqf

private ["_logic", "_units", "_activated"];
private ["_debug", "_myModuleParam1", "_myModuleParam2"];

_logic = [_this,0,objNull,[objNull]] call BIS_fnc_param;
_units = [_this,1,[],[[]]] call BIS_fnc_param;
_activated = [_this,2,true,[true]] call BIS_fnc_param;

missionNamespace setVariable ["zod_nav_module", _logic]; // make module available for scripts

if (_activated) then {
_debug = _logic getVariable ["Debug", false];
_myModuleParam1 = _logic getVariable ["MyModuleParam1", 0];
_myModuleParam2 = _logic getVariable ["MyModuleParam2", ""];
};

// ... 

Edited by mrflay
typo

Share this post


Link to post
Share on other sites

Gday Flay,

Thanks heaps for your reply - I had not found that link before.

Also thanks for taking the time to not only point me in the right direction but providing some extracts to get me started - a truly helpful reply!

There is a bit to digest in there but I think you have given me enough to get me started - time to put the head down and work through it.

Thanks again - much appreciated!

---------- Post added at 05:34 PM ---------- Previous post was at 04:38 PM ----------

Quick update - Thanks again... that made it so easy. I thought it might take a day of fiddling but within half an hour I got it functioning exactly as I wanted it.

Two very enthusiastic thumbs up mrFlay!

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  

×