Jump to content
Sign in to follow this  
anthonyfromtheuk

how to copy to clipboard gear being used

Recommended Posts

Having just downloaded Dslyexis Paperdoll update and finding out I cannot use it with vas. I am wondering how I copy current gear to the clipboard. I have this from somewhere I don't remember where (probably armaholic)

_obj = _this select 0; //the object that had the action
_caller = _this select 1; //unit that called the action
_id = _this select 2; //id of the action

_outp = "HEADGEAR  =  " + (headgear _caller)
+ "\n\nGOGGLES  =  " + (goggles _caller)
+ "\n\nPRIM. WEAPON  =  " + (primaryWeapon _caller) + "  =  " + (str primaryWeaponItems _caller)
+ "\n\nSEC. WEAPON  =  " + (secondaryWeapon _caller) + "  =  " + (str secondaryWeaponItems _caller)
+ "\n\nHANDGUN  =  " + (handgunWeapon _caller) + "  =  " + (str handgunItems _caller)
+ "\n\nASSIGNED ITEMS  =  " + (str assignedItems _caller)
+ "\n\nUNIFORM  =  " + (uniform _caller) + "  =  " + (str uniformItems _caller)
+ "\n\nVEST  =  " + (vest _caller) + "  =  " + (str vestItems _caller)
+ "\n\nBACKPACK  =  " + (backpack _caller) + "  =  " + (str backpackItems _caller);
//+ "\n\nALL WEAPONS  =  " + (str weapons _caller)
//+ "\n\nALL MAGAZINES  =  " + (str magazines _caller);

titleText [_outp, "BLACK IN", 120]; 

but that copies classnames and displays them on the screen. Anybody have any idea how I would copy to the clipboard the output from this? Or even better use this to generate the code to put in a units init just like Dslyecxis paperdoll does.

This would be ever so useful for quickly setting up NPCs for mission makers.

---------- Post added at 21:39 ---------- Previous post was at 21:29 ----------

Ah i figured it out, good old wiki - http://community.bistudio.com/wiki/copyToClipboard

---------- Post added at 21:54 ---------- Previous post was at 21:39 ----------

+ "this addweapon ' " + (primaryWeapon _caller) + " ';"

that works for primary weapon, this may take me a while :D

---------- Post added at 21:55 ---------- Previous post was at 21:54 ----------

Using

copyToClipboard (str (_outp));

instead of

titleText [_outp, "BLACK IN", 120];  

---------- Post added at 22:59 ---------- Previous post was at 21:55 ----------

Well i broke the script somehow and do not know how to split up the items to be copied correctly. Or stop it placing the entire copy inside quotes

_obj = _this select 0; //the object that had the action
_caller = _this select 1; //unit that called the action
_id = _this select 2; //id of the action

_copy = 'removeallweapons this;
removeGoggles this;
removeHeadgear this;
removeVest this;
removeUniform this;
removeAllAssignedItems this;'

  + "this addHeadgear'" + (headgear _caller)"';"

+ "this addGoggles '" + (goggles _caller)"';"

+ "this addWeapon '" + (primaryWeapon _caller)"';" 
+ "this addPrimaryWeaponItem '" + (str primaryWeaponItems _caller)"';"

+ "\n\nSEC. WEAPON  =  " + (secondaryWeapon _caller) 
+ "  =  " + (str secondaryWeaponItems _caller)

+ "\n\nHANDGUN  =  " + (handgunWeapon _caller) 
+ "  =  " + (str handgunItems _caller)

+ "this assignedItems '" + (str assignedItems _caller)"';"

+ "this addUniform '" + (uniform _caller)"';" 
+ "this additemtouniform '" + (str uniformItems _caller)"';"

+ "this addVest '" + (vest _caller)"';" 
+ "thisadditemtovest '" + (str vestItems _caller)"';"

+ "this addBackPack '" + (backpack _caller)"';" + "this additemtobackpack '" + (str backpackItems _caller)"';";

//+ "\n\nALL WEAPONS  =  " + (str weapons _caller)
//+ "\n\nALL MAGAZINES  =  " + (str magazines _caller);

copyToClipboard (str (_copy));
hintsilent "copied";

maybe someone can rescue this??? I will try again tomorrow.

Share this post


Link to post
Share on other sites
copyToClipboard format ["Weapons: %1 \n\n Magazines: %2 \n\n Items: %3 Vest: %4 \n\n Helmet: %5 \n\n Uniform: %6 \n\n Goggles: %7 \n\n Backpack: %8",weapons player, magazines player, items player, vest player, headgear player, uniform player, goggles player, backPack player];

Edited by cobra4v320

Share this post


Link to post
Share on other sites

Thanks for that cobra,I am interested in the changing the output as I figured out how to copy classnames, your way is easier than the way I was doing it though. I am after something like this

copytoclipboard format ["
       this addHeadgear '%1';
       this addVest '%2';
       this addUniform '%3';
       this addBackPack '%4';
       this addWeapon '%5';"
       headgear player, vest player,uniform player,backpack player, weapons player];
       hintsilent "copied";

But for everything the player has and that doesn't work for some reason. My main problem is how to get the output to be correct for the items and magazines as at the moment (besides that above just not working) it just lists them like "Magazines: ["16Rnd_9x21_Mag","16Rnd_9x21_Mag","HandGrenade"]" But i would like the output to be more like this this addMagazine "16Rnd_9x21_Mag"; this addMagazine "16Rnd_9x21_Mag"; this addMagazine "HandGrenade"; and so on for each mag and item. Basically so i can copy then paste into a units init and it will have everything the player copied from had. Thus allowing me to use VAS to set up NPCs loadouts quickly and easily. hope that makes sense....

Edited by Anthonyfromtheuk

Share this post


Link to post
Share on other sites

No it makes sense and that is how I do it to find positions and directions on the map for placing static weapons and soldiers.

copyToClipboard format ["this setPos %1; this setDir %2;",getPosATL player, getDir player];

The above code would look like this:

this setPos [1780.18,5856.43,0.00143862];    this setDir 296.772;

---------- Post added at 22:44 ---------- Previous post was at 22:26 ----------

So using this:

copytoclipboard format ["
   this addHeadgear '%1';
   this addVest '%2';
   this addUniform '%3';
   this addBackPack '%4';
   this addWeapon '%5';
   this addWeapon '%6';
   this addMagazines %7;
   this addMagazines %8;",
   headgear player, 
   vest player,
   uniform player,
   backpack player, 
   primaryWeapon player,
   handgunWeapon player,
   primaryWeaponMagazine player,
   handgunMagazine player
];

Will return this:

  this addHeadgear 'H_HelmetB';      
  this addVest 'V_PlateCarrier1_rgr';     
  this addUniform 'U_B_CombatUniform_mcam';     
  this addBackPack '';      
  this addWeapon 'arifle_MX_ACO_pointer_F';   
  this addWeapon 'hgun_P07_F';   
  this addMagazines ["30Rnd_65x39_caseless_mag"]; 
  this addMagazines ["16Rnd_9x21_Mag"];

Tested on a standard blufor rifleman

Share this post


Link to post
Share on other sites

copytoclipboard format ["
    removeHeadgear this;
    removeVest this;
    removeUniform this;
    removeBackpack this;
    removeallweapons this;
    removeGoggles this;

   this addHeadgear '%1';
   this addVest '%2';
   this addUniform '%3';
   this addBackPack '%4';
   this addWeapon '%5';
   this addWeapon '%6';
   this addMagazines '%7,1';
   this addMagazines '%8,1';
   this additem '%9';
   this addgoggles '%10';
   ",
   headgear player,
   vest player,
   uniform player,
   backpack player,
   primaryWeapon player,
   handgunWeapon player,
   primaryWeaponMagazine player,
   handgunMagazine player,
   items player,
   goggles player
];
       hintsilent "copied to clipboard";

thats what i have tried using and it works.. sort of, it outputs well enough until you get to magazines and then it goes wrong the copied output for magazines is in the wrong format

this addMagazines '["200Rnd_65x39_cased_Box"],1'; //this is what you get, it has quotation marks in the wrong place and the amount in the wrong place. for items it wraps them in [] for no apparent reason

Ive been looking at Riouken`s RSLO 3.0 to see how he calls saved loadouts and it seems this is just beyond me... Hopefully in the future somebody can make a working version of something simular to this as it would be ever so useful.

Youtubevideo of what happens when I enter the copied text. the AI, with no waypoint to move, goes off on a random run.

Edited by Anthonyfromtheuk

Share this post


Link to post
Share on other sites

Someone want to try this out for me, its for the current DEV version only as it uses the new container commands. I dont currently run DEV so output looks ok but needs testing.

if (!(isNil "actionID")) then { player removeAction actionID; };
actionID = player addAction ["equipment",{
_removeAll = "removeAllweapons this;
removeGoggles this;
removeHeadgear this;
removeVest this;
removeUniform this;
removeAllAssignedItems this; ";

_GEAR = "";
{
_item = call compile format["%1 player", _x];
if (!(_item == "")) then {
	_GEAR = _GEAR + format ["this add%1 %2; ", _x, str _item];
};
}forEach ["Headgear","Goggles","Uniform","Vest","Backpack"];


_weaponSlots = "";
{
_item = call compile format ["%1 player", _x];
if (!(_item == "")) then {
	_weaponSlots = _weaponSlots + format ["this addWeapon %1; ", str _item];
};
}forEach ["PrimaryWeapon","SecondaryWeapon","HandgunWeapon"];

_weaponMags = "";
{	
_weapon = _x;
_muzzles = getArray(configFile >> "cfgWeapons" >> _weapon >> "muzzles");
{
	if (!(_x == "this")) then {
		player selectWeapon _x;
	}else{
		player selectWeapon _weapon;
	};
	if (!(currentMagazine player == "")) then {
		_weaponMags = _weaponMags + format["this addMagazine %1; ",str currentMagazine player];	
	};
}forEach _muzzles;
}forEach weapons player;

_WEAPONS = _weaponMags + _weaponSlots;


_WEAPONITEMS = "";
{
_weaponSlot = _x;
{
	if (!(_x == "")) then {
		_WEAPONITEMS = _WEAPONITEMS + format ["this add%1Item %2; ", _weaponSlot, str _x];
	};
}forEach (call compile format ["%1Items player", _weaponSlot])
}forEach ["PrimaryWeapon","SecondaryWeapon","Handgun"];


_containerItems = "";
{
_container = _x;
{
	_containerItems = _containerItems + format["this addItemTo%1 %2; ", _container, str _x];
}forEach (call compile format ["%1Items player", _container]);
}forEach ["Uniform", "Vest", "Backpack"];

_assignedItems = "";
{
if (_x == "Binocular") then {
	_assignedItems = _assignedItems + format["this addWeapon %1; ", str _x];
}else{
	_assignedItems = _assignedItems + format["this linkItem %1; ", str _x];
};
}forEach assignedItems player;

_ITEMS = _containerItems + _assignedItems;

copyToClipboard (_removeAll + _GEAR + _WEAPONS + _WEAPONITEMS + _ITEMS);
hintSilent "copied";
}];

Adds an action to the player called equipment, when run outputs command list to clipBoard that can be placed in an init box for configuring unit load outs.

_____________________

This is about as close as i can get on stable with out to much messing around. Does pretty much everything other than the know problems of adding weapons to containers (vest etc) but should be good enough to get some loadout scripts sorted.

if (!(isNil "actionID")) then { player removeAction actionID; };
actionID = player addAction ["equipment",{
_removeAll = "removeAllWeapons this;
removeGoggles this;
removeHeadgear this;
removeVest this;
removeUniform this;
removeAllAssignedItems this; ";

_GEAR = "";
{
_item = call compile format["%1 player", _x];
if (!(_item == "")) then {
	_GEAR = _GEAR + format ["this add%1 %2; ", _x, str _item];
};
}forEach ["Headgear","Goggles","Uniform","Vest","Backpack"];


_weaponSlots = "";
{
_item = call compile format ["%1 player", _x];
if (!(_item == "")) then {
	_weaponSlots = _weaponSlots + format ["this addWeapon %1; ", str _item];
};
}forEach ["PrimaryWeapon","SecondaryWeapon","HandgunWeapon"];

_weaponMags = "";
{
_weapon = _x;
_muzzles = getArray(configFile >> "cfgWeapons" >> _weapon >> "muzzles");
{
	if (!(_x == "this")) then {
		player selectWeapon _x;
	}else{
		player selectWeapon _weapon;
	};
	if (!(currentMagazine player == "")) then {
		_weaponMags = _weaponMags + format["this addMagazine %1; ",str currentMagazine player];
	};
}forEach _muzzles;
}forEach weapons player;

_WEAPONS = _weaponMags + _weaponSlots;


_WEAPONITEMS = "";
{
_weaponSlot = _x;
{
	if (!(_x == "")) then {
		_WEAPONITEMS = _WEAPONITEMS + format ["this add%1Item %2; ", _weaponSlot, str _x];
	};
}forEach (call compile format ["%1Items player", _weaponSlot])
}forEach ["PrimaryWeapon","SecondaryWeapon","Handgun"];


_containerItems = "";
{
_container = _x;
{
	_item = _x;
	if ( _item != "Binocular" ) then {
		if ( (isClass (configFile >> "cfgWeapons" >> _item)) ) then {
			if ( (getNumber(configFile >> "cfgWeapons" >> _item >> "type")) in [1,2,4] ) then {
				_containerItems = _containerItems + format["this addWeapon %1; ", str _item];
			}else{
				_containerItems = _containerItems + format["this addItem %1; ", str _item];
			};
		}else{
			_containerItems = _containerItems + format["this addMagazine %1; ", str _x];
		};
	};
}forEach (call compile format ["%1Items player", _container]);
}forEach ["Uniform", "Vest", "Backpack"];

_assignedItems = "";
{
if (_x == "Binocular") then {
	_assignedItems = _assignedItems + format["this addWeapon %1; ", str _x];
}else{
	_assignedItems = _assignedItems + format["this linkItem %1; ", str _x];
};
}forEach assignedItems player;

_ITEMS = _containerItems + _assignedItems;

copyToClipboard (_removeAll + _GEAR + _WEAPONS + _WEAPONITEMS + _ITEMS);
hintSilent "copied";
}];

Edited by Larrow

Share this post


Link to post
Share on other sites

This is brilliant! exactly what I wanted. Thank you for sharing this it will be very very useful to me and hopefully others to!

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  

×