Jump to content
Sign in to follow this  
Icaruk

Moving items from one listbox to another one.

Recommended Posts

At the moment I have 2 items:

init.sqf

missionNamespace setVariable ["Log",1];
missionNamespace setVariable ["Wood",1];

When you open he menu:

craftingmenu.sqf

list = ["Log", "Wood"];
Q = [Log, Wood];


inventory = [];

{
_itemName = list select _forEachIndex;
_itemQ = Q select _forEachIndex;

_where = count invntory;

inventario set [_where, [_itemNname, _itemQ]];
} foreach list;



table = [];


createDialog "crafting_dialog";
{

_item = format ["%2 x %1", _x select 1, _x select 0];
_index = lbAdd [1500, _item];


} foreach inventory;

When you click the button to move the selected item from the left to the right box:

move.sqf

_selected = _this select 0;
¿?

Here is the problem, I don't know how to get the variable name and value from the listbox, any thoughts? Also, I would like too when you have 0 units from one item, it just doesn't show on the listbox.

Share this post


Link to post
Share on other sites

Post some code you are using or I can't help :)

Share this post


Link to post
Share on other sites
Post some code you are using or I can't help :)

All the code I'm using is there, except the dialogs, 1500 is my inventory 1501 is the table.

Share this post


Link to post
Share on other sites
All the code I'm using is there, except the dialogs, 1500 is my inventory 1501 is the table.

You are saying that the lbData command is returning an empty string, I can't see why if you don't show me how you're using the command.

Share this post


Link to post
Share on other sites
You are saying that the lbData command is returning an empty string, I can't see why if you don't show me how you're using the command.

You mean this?

When you select something on the left listbox and then click the "move button" it exec this:

move.sqf

_selected = lbData [1500,0];
hint format ["%1",_selected];

Share this post


Link to post
Share on other sites

You have to use lbSetData first when adding the listbox rows, otherwise there will be no data to grab.

Share this post


Link to post
Share on other sites
You have to use lbSetData first when adding the listbox rows, otherwise there will be no data to grab.

But I need to set 2 values, name of the item (variable) and quantity :/

Share this post


Link to post
Share on other sites
But I need to set 2 values, name of the item (variable) and quantity :/

This can be accomplished by setting an array. Such as...

lbSetData [1500, 0, str (["Log", 1])];

Then use lbData like so...

_data = call compile (lbData [1500, 0]); //Returns actual array
_item = _data select 0;
_amount = _data select 1;

Share this post


Link to post
Share on other sites
This can be accomplished by setting an array. Such as...

lbSetData [1500, 0, str (["Log", 1])];

Then use lbData like so...

_data = call compile (lbData [1500, 0]); //Returns actual array
_item = _data select 0;
_amount = _data select 1;

I'll try, thanks!

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  

×