Jump to content
Sign in to follow this  
lxets

setVariable on Controls

Recommended Posts

Hi, i'm trying to create a shop menu which uses ctrlCreate to create images, text & buttons. On the buttons, I want to set some data, such as a price for an item and the items class name, and I am trying to use setVariable on the button to set an array of data, and when the button is pressed the eventhandler will run a script which retrieves these variables, for use in another script. Im under the impression that this would work as reading setVariable on the wiki says 'Control setVariable Array (since Arma 3 v1.55.133553)'.

_button = _weaponList ctrlCreate ["RscButtonMenu", _IDC , CONTROL(1000,1001)];
_button ctrlSetText "Buy Weapon";
_button setVariable ["data",[_weaponClassname,_weaponCost]];
_button ctrlSetEventHandler ["ButtonClick", "[_this] spawn life_fnc_test;"];

and on the other script

_control = _this select 0;
_itemData = _control getVariable "data";

however, I am getting the error

 Error getvariable: Type Array, expected Namespace,Object,Group,Display (dialog),Control,Team member,Task,Location

Any help would be appreciated, im not sure if this is the best way to do it, with ctrlCreate, but I want to avoid using list boxes for the moment even though I know that is alot easier.

 

Share this post


Link to post
Share on other sites

Try

_this spawn life_fnc_test;
//or even
_this call life_fnc_test;

instead of 

[_this] spawn life_fnc_test;

Share this post


Link to post
Share on other sites

 

Try

_this spawn life_fnc_test;
//or even
_this call life_fnc_test;

instead of 

[_this] spawn life_fnc_test;

 

Ah yea, that worked great, thanks. Always the small things  :D

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  

×