Jump to content

TeTeT

Configuring a module in Eden?

Recommended Posts

Hello,

 

I have written a module for carpet bombing for Sabre's secret weapon and Unsung. Unfortunately it's quite hard to use as one needs to know the class name of the plane (easy to get in Eden though) and the bomb weapon classname (very hard to get, through config viewer). Now I want to ease the setup of this module via a custom entry in the tools menu of Eden where one can select a bomber and bomb type through browsing an additional config entry, CfgCarpet.

Before setting up dialog and what not, I tried to alter the config of a script placed unsung carpet bomb module in the Eden debugger. When setting the 'bomb' variable this change is not reflected in the module, though in the debug script the new value is shown:

 

e = create3DENEntity ["Logic", "uns_ModuleCarpet", screenToWorld [0.5, 0.5]];
systemChat str (allVariables e);
systemChat str (e getVariable "bomb");
e setVariable ["bomb", "flip"];
systemChat str (e getVariable "bomb");

The last systemChat prints flip. But when I double click the uns_ModuleCarpet Eden entity I still see the old value.


Any solution to this, I suspect that the setVariable doesn't work to well with Modules. Alternative approaches to the problem of configuring a module is also welcome!

 

Cheers,

TeTeT

 

 

  • Like 1

Share this post


Link to post
Share on other sites

You cannot use setVariable, you need to use set3denAttribute.

e set3DENAttribute[ "bomb", "flip" ];

Where bomb is the name given to the attribute in the modules config. This is not necessarily the label shown in Eden when viewing the modules attributes.

 

Eden is basically a running mission, any values (like setVariable) are lost on save/preview etc you need to use specific Eden commands for things to be saved. Much the same as you use create3DENEntity instead of createVehicle/Unit

Share this post


Link to post
Share on other sites

Thanks @Larrow, the 3DEN Attribute is a good pointer, but it does not seem to work with Modules. E.g. I can get and change the 'name' 3DEN Attribute as it is defined on the module, but the arguments are not visible as attribute. They module is defined like this, and I wonder if there is any Eden mapping between Arguments and Attributes?

 

	class uns_ModuleCarpet: Module_F
	{
		scope = 2;
		is3DEN = 0;
		displayName = "Unsung Carpet Bombing";
		category = "UnsungModules";
		function = "uns_mbox_fnc_moduleCarpet";
		functionPriority = 3;
		isGlobal = 0;
		isPersistent = 1;
		isTriggerActivated = 0;
		isDisposable = 0;
		curatorCost = 5;
		icon = "\uns_icons\uns_sml.paa";
		class Arguments: ArgumentsBaseUnits
		{
			class Units: Units{};
			class Type
			{
				displayName = "Plane Type";
				description = "Class name of the plane to bomb";
				typeName = "STRING";
				defaultValue = "uns_A6_Intruder_BMB";
			};
			class Amount
			{
				displayName = "Number of bombers";
				description = "Amount of bombers to do the raid";
				typeName = "NUMBER";
				defaultValue = 4;
			};
			class Bomb
			{
				displayName = "Bomb Weapon";
				descriptionName = "Class name of the weapon to release bombs";
				typeName = "STRING";
				defaultValue = "Uns_Mk83Launcher_dl";
			};
			class BombAmount
			{
				displayName = "Bombs per bomber";
				description = "Number of bombs per bomber";
				typeName = "NUMBER";
				defaultValue = 15;
			};
			class BayOpenDelay
			{
				displayName = "Bay Door Delay";
				descriptionName = "Delay in seconds when opening bomb bay doors";
				typeName = "NUMBER";
				defaultValue = 0;
			};
			class InitialAlt
			{
				displayName = "Bomber initial altitude";
				descriptionName = "Altitude for bomber upon spawn";
				typeName = "NUMBER";
				defaultValue = 1000;
			};
			class VirtualFlakDelay
			{
				displayName = "Virtual Flak Delay";
				descriptionName = "Maximum delay in seconds between virtual flak shots, 0 is disabled";
				typeName = "NUMBER";
				defaultValue = 2;
			};
		};
		class ModuleDescription: ModuleDescription
		{
			description = "Unsung Carpet Bombing";
			sync[] = {};
		};
	};

 

Edited by TeTeT
clarification of question

Share this post


Link to post
Share on other sites
  On 10/21/2019 at 2:56 PM, TeTeT said:

but the arguments are not visible as attribute

Ah ok they are arguments only. Of which arguments are automatically copied to the object( module/logic ) at object creation, as variables on the object, named as the arguments class name.

Mileage may very and needs thoroughly testing but, you can set the modules init through attributes, in which case you can try setting the the arguments variables from the modules init at mission initialisation. ie

For instance, take the standard BI support supply drop virtual. Set one up as standard, player > requester > virtual drop.

Then in Eden select only the virtual drop module and run the code below from the debugConsole..

get3denselected "Logic" select 0 set3denAttribute[ "init", "
	this setVariable[ 'BIS_SUPP_crateInit', '
		clearWeaponCargoGlobal _this;
		clearMagazineCargoGlobal _this;
		clearItemCargoGlobal _this;
		clearBackpackCargoGlobal _this
	']
"];

If you now look at the modules init you will see that code has been applied to it.

The crate init argument of the virtual supply drop is also an argument with no attribute. The above sets the modules init so when the module is initialised in the mission it sets the variables of the crate init argument on itself, with the code to clear out the crate contents.

 

Sort of a hacky solution and as I said would need thoroughly testing. The crate init as above is never run until the crate is actually spawned, so if arguments your are trying to change are read by the module as soon as it is created there maybe timing issues.

  • Thanks 1

Share this post


Link to post
Share on other sites

Thanks @Larrow, that did the trick.

 

I now have this dialog defined:

 

class uns_cb
{
	idd = 2019;
	movingEnable = true;
	onLoad = "_this call uns_mbox_fnc_carpetLoad;";
	class controls
	{
		////////////////////////////////////////////////////////
		// GUI EDITOR OUTPUT START (by TeTeT, v1.063, #Dujeja)
		////////////////////////////////////////////////////////

		class uns_cb_frame: RscFrame
		{
			idc = 1800;
			x = 0.2375 * safezoneW + safezoneX;
			y = 0.206013 * safezoneH + safezoneY;
			w = 0.6 * safezoneW;
			h = 0.6 * safezoneH;
			colorBackground[] = {0.1,0.1,0.1,0.5};
		};
		class uns_cb_listBoxPlane: ctrlListbox
		{
			idc = 1500;
			x = 0.28125 * safezoneW + safezoneX;
			y = 0.262011 * safezoneH + safezoneY;
			w = 0.291667 * safezoneW;
			h = 0.4 * safezoneH;
		};
		// class uns_cb_listBoxBomb: ctrlListbox
		// {
		// 	idc = 1501;
		// 	x = 0.602083 * safezoneW + safezoneX;
		// 	y = 0.262011 * safezoneH + safezoneY;
		// 	w = 0.2 * safezoneW;
		// 	h = 0.4 * safezoneH;
		// };
		class uns_cb_buttonOk: CtrlButton
		{
			idc = 1600;
			text = "Ok"; //--- ToDo: Localize;
			x = 0.733333 * safezoneW + safezoneX;
			y = 0.709991 * safezoneH + safezoneY;
			w = 0.0583333 * safezoneW;
			h = 0.0699969 * safezoneH;
			action = "systemChat 'setting up carpet bomb module'; [] call uns_mbox_fnc_carpetTool;";
		};
		class uns_cb_buttonCancel: CtrlButton
		{
			idc = 1601;
			text = "Cancel"; //--- ToDo: Localize;
			x = 0.295833 * safezoneW + safezoneX;
			y = 0.709991 * safezoneH + safezoneY;
			w = 0.0583333 * safezoneW;
			h = 0.0699969 * safezoneH;
			action = "(findDisplay 2019) closeDisplay 0; systemChat 'Carpet Bomb setup cancelled';";
		};
		////////////////////////////////////////////////////////
		// GUI EDITOR OUTPUT END
		////////////////////////////////////////////////////////

	};
};

 

The function to load the listboxes is incomplete, will be driven from config later on, but basically it works:

 

// Written by TeTeT for Unsung

params ["_dsp"];

private _lbPlanes = _dsp displayCtrl 1500;
{
	private _idx = _lbPlanes lbAdd (_x # 0);
	_lbPlanes lbSetData [_idx, _x # 1];
} forEach [ ["A-4 (10 * Mk82 500 lbs)", "uns_A4B_skyhawk_BMB;Uns_Mk82Launcher_dl;10"],
            ["A-6 (15 * Mk83 1000 lbs)", "uns_A6_Intruder_BMB;Uns_Mk83Launcher_dl;15"],
            ["A-7 (14 * Mk83 1000 lbs)", "uns_A7N_BMB;Uns_Mk83Launcher_dl;14"],
            ["F-100 (6 * Napalm 500lbs)", "uns_f100b_CAS;Uns_NapalmLauncher_500_dl;6"] ];

 

The carpetTool function that sets the variables in the module via init:

 

// Written by TeTeT for Unsung, with help from Larrow
// https://forums.bohemia.net/forums/topic/226173-configuring-a-module-in-eden/
private _dsp = findDisplay 2019;

private _ctrl = _dsp displayCtrl 1500;
private _idx = lbCurSel _ctrl;
private _data = _ctrl lbData _idx;

// systemChat str _data;

private _dataArray = _data splitString ";";

private _e = create3DENEntity ["Logic", "uns_ModuleCarpet", screenToWorld [0.5, 0.5]];
// _e set3DENAttribute ["name", "PreconfiguredCarpetBomb"];
_e set3DENAttribute[ "init", format ["
	this setVariable[ 'Type', '%1'];
	this setVariable[ 'Bomb', '%2'];
	this setVariable[ 'BombAmount', %3];
", _dataArray # 0, _dataArray # 1, parseNumber(_dataArray # 2)]];

_dsp closeDisplay 0;

 

Thanks again for your help and pushing in the right direction!

 

Cheers,

TeTeT

Edited by TeTeT
message content
  • 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

×