Jump to content
Drongo69

Interaction with inventory items?

Recommended Posts

Is it possible to activate scripts at the mission level by clicking on items in the inventory? It would be very useful in conjunction with addons such as Scorch's Inventory Items. If this is not yet possible, it would be an extremely useful command to add.

Share this post


Link to post
Share on other sites

I know nothing about dialogs but it was done in dayz, so I'd say yes.

I'd guess you use a combinat

---------- Post added at 11:03 AM ---------- Previous post was at 11:01 AM ----------

Posting from phone...

I'd guess you use a combination of waiting for the gear dialog and then use an ui event handler.

Someone should know this, or you could looking around in. The dayz code (not an easy task)

Share this post


Link to post
Share on other sites

Yes its possible to run scripts from clicking on items in your inventory. As cuel says you need to wait for the inventory dialog to be opened then set an event on the control you want to monitor that runs your function.

As a quick example run this in the debug console.

handle = [] spawn {
   fnc_test = { 
   	_idc = ctrlIDC (_this select 0);
   	_selectedIndex = _this select 1;
   	_data = format ["Data\n%1\n________\n",lbData [_idc, _selectedIndex]];
   	_text = format ["Text\n%1\n________\n",lbText [_idc, _selectedIndex]];
   	_value = format ["Value\n%1\n________\n",lbValue [_idc, _selectedIndex]];
   	_pic = format ["Picture\n%1\n________\n",lbPicture [_idc, _selectedIndex]]; 
   	hint format["Selected Uniform Index: %1\n%2%3%4%5",_selectedIndex,_data,_text,_value,_pic];
   	false
   };
   while {true} do {
       waituntil {!(isnull (finddisplay 602))};
       hint "Inventory has been opened\nAdding event to uniform listbox";
       ((findDisplay 602) displayCtrl 633) ctrlSetEventHandler ["LBSelChanged", "_this call fnc_test"];
       waituntil {isnull (finddisplay 602)};
   };
};  

When you open your inventory and click on any item in your uniform it will hint what that items description is.

Edited by Larrow
Updated script to show more info
  • Like 1

Share this post


Link to post
Share on other sites

Thank you very much! With some modification I could run scripts when clicking on magazines. For some reason non-magazine weapons (such as medkits or the custom items from Scorch's pack) would not be detected if clicked upon.

Also, how would I go about finding the required numbers to use in findDisplay and displayCtrl for the rest of the inventory spaces? Is there a reference page somewhere?

Share this post


Link to post
Share on other sites
For some reason non-magazine weapons (such as medkits or the custom items from Scorch's pack) would not be detected if clicked upon.

They were detected as you would see the hint come up, just the data was empty. I noticed Fak's were not showing, as i said was only a quick example, you would need to look see what other data/text is there to pull from each slot.
Also, how would I go about finding the required numbers to use in findDisplay and displayCtrl for the rest of the inventory spaces?
If you unpack your Arma3/Addons/UI_f.pbo in there you will find:-

config.cpp <- Inventory UI starts at line 34681

hpp/defineResincl.inc <- has the defined idd & idc numbers, inventory starts at line 785

// Futura ui

#define IDD_FUTURAGEAR 602

// FUTURA GEAR controls

#define IDC_FG_PRIMARY 610

#define IDC_FG_SECONDARY 611

#define IDC_FG_HANDGUN 612

// prefix 620 means slot items

//---

#define IDC_FG_MAP 6211

#define IDC_FG_COMPASS 6212

#define IDC_FG_WATCH 6213

#define IDC_FG_RADIO 6214

#define IDC_FG_GPS 6215

#define IDC_FG_GOGGLES 6216

#define IDC_FG_HMD 6217

#define IDC_FG_BINOC 6238

#define IDC_FG_BACKPACK2 6239

#define IDC_FG_HEADGEAR 6240

// prefix 630 means slot container items(uniform, vest, backpack)

#define IDC_FG_UNIFORM_SLOT 6301

#define IDC_FG_VEST_SLOT 6302

#define IDC_FG_BACKPACK_SLOT 6303

/// containers load

#define IDC_FG_UNIFORM_LOAD 6304

#define IDC_FG_VEST_LOAD 6305

#define IDC_FG_BACKPACK_LOAD 6306

#define IDC_FG_GROUND_LOAD 6307

#define IDC_FG_TOTAL_LOAD 6308

//---

#define IDC_FG_MAGAZINES 618

// primary

#define IDC_FG_PW_MUZZLE 620

#define IDC_FG_PW_OPTICS 621

#define IDC_FG_PW_FLASHLIGHT 622

#define IDC_FG_PW_MAGAZINE 623

// secondary

#define IDC_FG_SW_MUZZLE 624

#define IDC_FG_SW_OPTICS 625

#define IDC_FG_SW_FLASHLIGHT 626

#define IDC_FG_SW_MAGAZINE 627

// handgun

#define IDC_FG_HG_MUZZLE 628

#define IDC_FG_HG_OPTICS 629

#define IDC_FG_HG_FLASHLIGHT 630

#define IDC_FG_HG_MAGAZINE 631

#define IDC_FG_GROUND_ITEMS 632

#define IDC_FG_CHOSEN_CONTAINER 640

// #define IDC_FG_BACKPACK_ITEMS 633

// #define IDC_FG_ITEMS 619

// new inventory

// filter

#define IDC_FG_GROUND_FILTER 6554

// images which will painted over containers during DnD state

#define IDC_FG_GROUND_MARKER 6385

#define IDC_FG_CONTAINER_MARKER 6325

#define IDC_FG_CHOSEN_MARKER 6405

#define IDC_FG_VEST_CONTAINER 638

#define IDC_FG_UNIFORM_CONTAINER 633

#define IDC_FG_BACKPACK_CONTAINER 619

#define IDC_FG_VEST_TAB 6381

#define IDC_FG_VEST_TEXT 6382

#define IDC_FG_UNIFORM_TAB 6331

#define IDC_FG_UNIFORM_TEXT 6332

#define IDC_FG_BACKPACK_TAB 6191

#define IDC_FG_BACKPACK_TEXT 6192

#define IDC_FG_CHOSEN_TAB 6401

#define IDC_FG_CHOSEN_TEXT 6402

#define IDC_FG_GROUND_TAB 6321

#define IDC_FG_GROUND_TEXT 6322

///////////////

/// weight info

#define IDC_FG_GROUND_WEIGHT 634

#define IDC_FG_BACKPACK_WEIGHT 635

#define IDC_FG_ITEMS_WEIGHT 636

/// player info

#define IDC_FG_TOTAL_WEIGHT 637

Handy pages to have bookmarked

Dialog Overview

IDC types from BISim

UI event handlers

UI Editor

UI scripting commands

EDIT: Updated my first post with a script to get as much info as i could find about an idc Listbox's selected index.

Data if filled in seems to be class name.

Text seems to be displayname from class.

Value is just the index number.

Picture gives you the path to the items paa.

So if the class name is not present then your most likely going need a little config scripting wizardry to get the info for the object, or set up your own array for items you know your going to need to reference.

Edited by Larrow

Share this post


Link to post
Share on other sites

Thank you so much, Larrow, that's a huge help. I really appreciate it. Hopefully I can figure out the rest from here.

Share this post


Link to post
Share on other sites

For anyone else who finds this in the future, as of December 13, 2015, Arma 3 version 1.54 Stable, the Inventory UI information starts around line 41160, in the config.cpp. Refer to larrow's earlier post on file location.

Share this post


Link to post
Share on other sites

Hello everyone,

 

For those finding this as of May, 2016, a few things have changed.  

 

Config.cpp no longer exists, it is now stored in Config.bin.    To open this file you need to convert it back into a cpp.   Use the CfgConvert tool, part of Arma 3 Tools.   After conversion, the file is plain-text readable.

Currently the gear dialog can be found at line 20595.  This is always subject to change with every release of A3, in best practice search for "RscDisplayGear".

 

 

For those of us new to digging around, this file only contains the dialog information.  If you were looking to add virtual items, this is just the beginning as handlegear.sqf will need to be modified as well.

 

 

Good luck!

Share this post


Link to post
Share on other sites

Config.cpp no longer exists, it is now stored in Config.bin.

Its always been config.bin. This just means that you have not de-binarised the extracted files.

As you mention, either Arma3Tools or mikeroos to de-binarise it to a readable config.cpp

 

Currently the gear dialog can be found at line 20595. This is always subject to change with every release of A3, in best practice search for "RscDisplayGear".

RscDiplayGear is not the inventory. You need to look for RscDisplayInventory as of 1.58 this can be found at 41916.

Its function is "\a3\ui_f\scripts\igui\rscdisplayinventory.sqf" but there is nothing here to change as most of the inventory functionality is handled by the engine.

If you want to add new items then you need to make a basic Item/Magazine addon inheriting from ItemCore/CA_Magazine respectively or similar.

Although possible to inject things into the inventory listboxes it is not the ideal way to handle it.

Share this post


Link to post
Share on other sites

Thanks Larrow.

 

 

My goal is to show virtual items in the inventory without an add-on.  My goal was to copy the whole inventory system and implement it over the built in version.  The issue I seem to be having, I am unable to find what script opens the inventory window and populates it with the assets you have?  handlegear.sqf is the only thing I could find that was remotely similar, but being a novice in this leaves me limited.   So far I cant find where it all starts.

 

At least I don't give up!

Share this post


Link to post
Share on other sites

In the interest of not loosing my mind, I think injecting may be a good option if I cant figure this out, so that's plan B anyways.

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

×