chief_wiggum 17 Posted December 29, 2014 Hey Guys! Just wanted to know if it's possible to transfer a string to a function which uses it as conditon for THEN command? Sounds bewildering? That's what i want for example: ["player != vehicle player"] call MY_FUNCTION; MY_FUNCTION: If ([color="#FF0000"]CONDITION WITHOUT QUOTES[/color]) then {hint "You are in a vehicle!";}; I hope it was understandable and i also hope somebody can help me ;) ~Chief Share this post Link to post Share on other sites
jshock 513 Posted December 29, 2014 Use the compile command. Share this post Link to post Share on other sites
chief_wiggum 17 Posted December 29, 2014 But compile command replaces the quotes against curly braces and, If ({player != vehicle player}) then ...... delivers errors. Share this post Link to post Share on other sites
Larrow 2820 Posted December 29, 2014 If (call compile (_this select 0)) then {hint "You are in a vehicle!";}; Share this post Link to post Share on other sites
chief_wiggum 17 Posted December 29, 2014 If (call compile (_this select 0)) then {hint "You are in a vehicle!";}; OK, that sounds logically, but if i execute it, it doesn't return anything. Why? Fuction call: ["player != vehicle player"] call my_function my_function: my_function = { If (call compile (_this select 0)) then {hint "You are in a vehicle";}; }; Share this post Link to post Share on other sites
shuko 59 Posted December 29, 2014 What exactly are you trying to do that would require such, rather ugly, coding? Why can't you use proper structures and conditions? Share this post Link to post Share on other sites
Larrow 2820 Posted December 29, 2014 Meh wouldnt exactly call it ugly, it is a means to an end, although of relatively niche usage. It is used countless times through out BIS code, BIS_fnc_MP, addStackedEventHandler, anywhere where you enter a code string like modules for example. Granted it may be not what the OP needs depending on what they are actually trying to do. _________________________ Fuction call: ["player != vehicle player"] call my_function my_function: my_function = { If (call compile (_this select 0)) then {hint "You are in a vehicle";}; }; Works ok here Wiggum! What do you mean by 'Does not return anything"? All it does it Hint a message if you are in a vehicle, when called. Share this post Link to post Share on other sites
chief_wiggum 17 Posted December 29, 2014 (edited) I'm filling a listbox via a function and some entrys should only be added to the listbox if the condition, which the user transfered, returns true. OK, I working on a gui-actionmenu which contains of 2 listboxes. Users can add Entrys to Listbox 1 via a function. Inside that function-call users can also specify which entrys are going to be added to listbox 2 if the entry in listbox 1 was clicked. Could look like this:https://www.dropbox.com/s/hfdy23yuh4upp1q/2014-12-29_00001.jpg?dl=0 Now, if the addEntry function was called, an other function will pack it a into an array. Later on (if the user opens the dialog) the array of added Entrys is used to fill the 2nd Listbox. And now i want it to be possible to set a condition for the entry to be added. The addEntry fuction call looks like this: [ "Listbox 1 entryname", // NAME OF THE MAIN ENTRY IN LISTBOX 1 "cw_acim_menuentry", // ENTRY CLASSNAME [ ["Listbox 2 entryname","execVM ""Eject.sqf""",[color="#FF0000"]"player != vehicle player"[/color]] //NAME OF THE ENTRY IN LISTBOX2, ACTION AND[color="#FF0000"] CONDITION[/color] ], "Listbox 2 Header" //HEADER OF LISTBOX 2 ] call fnc_cw_gui_templates_menu_addEntry; The fillListbox2 function looks like this: fnc_cw_gui_templates_menu_fillListbox = { _supentrys = _this select 0; //In my example this would be: [["Listbox 2 entryname","execVM ""Eject.sqf""","player != vehicle player"]] { _SupEntryName = _x select 0; //THIS IS: "Listbox 2 entryname" _SupEntryAction = _x select 1; //THIS IS: "execVM ""Eject.sqf""" _condition = _x select 2; //THIS IS: "player != vehicle player" If ([color="#FF0000"]NEED DAMN CONDITION FROM ABOVE HERE[/color]) then { _index = lbAdd [1501, _SupEntryName]; lbSetData [1501, _index, _SupEntryAction]; }; }forEach _supentrys; Now all i need to know is how to get that damn string condition to work with the (). And yes, your brain meant to be smoking like a locomotive right now. ;) //Larrow you ninja!;) I know it should work, but the hint doesn't comes up after call. ..And yes!I'm sitting in a vehicle. :/ It has to work. BIS also used it with addAction. DAMN! It works! Just replaced NEED DAMN CONDITION FROM ABOVE HERE with call compile _condition. I'dont know why the function in post #5 didn't work, but jeah..... , just srew it! ;D THANKS A LOT GUYS! Edited December 29, 2014 by AWC_Chief_Wiggum Share this post Link to post Share on other sites