pierremgi 4739 Posted August 13, 2017 Hi, I'm trying to delete a task from its own description. (not mark it as completed or canceled) so, I can write a code inside the description with execute expression. The problem is there is no parameter passed for this code. So far, i'm writing: _tsk = [_mk, _tgt, ["new task for " + format [_tgtText + toString [60,98,114,47,62] + _mkText + toString [60,98,114,47,62] + "<execute expression=' hint str [""hello"",_tsk,_mk] '>Erase this task</execute>"],_mkTitle,_mk], _mkPos, "AUTOASSIGNED", 1, true, true, _tskType, false] call BIS_fnc_setTask; The problem is neither the use of this function,nor the local variables working fine out of execute expression context. The problem is the result of the hint : [hello,any,any] I'd like to refer at something in regard of the selected task (not assigned but selected as i'm reading its description). Any idea? Share this post Link to post Share on other sites
mrcurry 470 Posted August 14, 2017 Ah locality thou art one uncompromising bitch. It seems to me like both your variables are typ String. Try format: format ["<execute expression=' hint str ["hello","%1" ,"%2" ]'>Erase this task</execute>", _tsk, _mk] Edit: Just realised unless _tsk is defined beforehand that won't work either, just passing the tasks tag should though. Share this post Link to post Share on other sites
killzone_kid 1326 Posted August 14, 2017 20 hours ago, pierremgi said: "<execute expression=' hint str ["hello",_tsk,_mk] '>Erase this task</execute>" This is not a valid string Share this post Link to post Share on other sites
mrcurry 470 Posted August 14, 2017 Ha! Can't believe I missed that! *facepalm* Share this post Link to post Share on other sites
pierremgi 4739 Posted August 14, 2017 1 hour ago, killzone_kid said: This is not a valid string sorry for that, I simplified it here, missing the double quote. "<execute expression=' hint str [""hello"",_tsk,_mk] '>Erase this task</execute>" (corrected above) The valid string returned ["hello",any,any], not an error, as mentioned above. @mrcurry a hint format doesn't fix the problem. You're just losing the any returns for a simple hello hint. But that doesn't change the problem. What I need is something referring to the opened (selected) task, or its associated marker at least. I tested this and _this, there is no special variable like this passed to the code. I tried something with supported tags like these , but that returns errors. I'm not familiar with HTML or else code. Searching in BI diary functions, not so much documented. Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted August 14, 2017 Why not use global variables? _tsk is local, hence will not exist inside the task descriptions execute command scope. Is _mk defined earlier in the script? Where does that come from? Looks like you're overcomplicating things. Cheers Share this post Link to post Share on other sites
killzone_kid 1326 Posted August 14, 2017 why not use BIS_fnc_taskSetDescription after you set task and know your task id? Share this post Link to post Share on other sites
pierremgi 4739 Posted August 14, 2017 1 minute ago, Grumpy Old Man said: Why not use global variables? _tsk is local, hence will not exist inside the task descriptions execute command scope. Is _mk defined earlier in the script? Where does that come from? Looks like you're overcomplicating things. Cheers Just because, players can create multiple tasks on the map. (working fine). I'd like to allow the players deleting these tasks. With global variables, I deleted the task(s) in creation order, not the task open in map. I already tried missionNameSpace setvariable ["mk", ...] . That works for the last one. Share this post Link to post Share on other sites
pierremgi 4739 Posted August 14, 2017 2 minutes ago, killzone_kid said: why not use BIS_fnc_taskSetDescription after you set task and know your task id? I tried also. The problem remains the code. As GOM said, a global variable could be the solution, but not discriminative on my tasks/markers so far. Share this post Link to post Share on other sites
pierremgi 4739 Posted August 14, 2017 Here is the full script. Just add it in a trigger with true condition, or console: Spoiler _MGI_taskOnMarker = addMissionEventHandler ["map",{ if (_this select 0) then { [] spawn { _mks = allMapMarkers; private ["_tgt","_tgtText","_mk"]; while {visibleMap && hasInterface} do { waitUntil {!(_mks isEqualTo allMapMarkers)}; if (count allMapMarkers > 0) then { private _mk = allMapMarkers select (count allMapMarkers - 1); _mkType = markerType _mk; if (_mkType in ["hd_objective","hd_ambush","hd_destroy","hd_pickup","hd_join"]) then { _mkText = markerText _mk; _mkPos = getMarkerPos _mk; _tskType = switch (_mkType) do { case "hd_objective": {"target"}; case "hd_ambush": {"attack"}; case "hd_destroy": {"destroy"}; case "hd_pickup": {"interact"}; case "hd_join": {"meet"}; }; _mkTitle = switch (_mkType) do { case "hd_objective": {"new objective"}; case "hd_ambush": {"ambush here"}; case "hd_destroy": {"destroy"}; case "hd_pickup": {"pick up"}; case "hd_join": {"join"} }; _channel = _mk select [count _mk - 1]; call { if (_channel == "0") exitWith {_tgt = true; _tgtText = "all!"}; if (_channel == "1") exitWith {_tgt = side player; _tgtText = "our camp!"}; if (_channel == "2") exitWith {_tgt = allPlayers select {side _x == side player && _x == leader _x}; _tgtText = "our camp!"}; if (_channel == "3") exitWith {_tgt = Group player; _tgtText = "our group!"}; if (_channel == "4") exitWith {_tgt = crew vehicle player; _tgtText = "our crew!"}; _tgt = player; _tgt = "ourselves!" }; _tsk = [str(_veh), _tgt, ["new task for " + format [_tgtText + toString [60,98,114,47,62] + _mkText + toString [60,98,114,47,62] + "<execute expression='hint str [""hello"",_tsk,_mk] '>Cancel task</execute>"],_mkTitle,_mk], _mkPos, "AUTOASSIGNED", 1, true, true, _tskType, false] call BIS_fnc_setTask; _mk setMarkerShape "ellipse"; _mk setMarkerBrush "Border"; _mk setMarkerSize [100,100]; _mk setMarkerAlpha 0.7; _mk setMarkerColor "colorRed"; [_tsk,_mk,_veh] spawn { params ["_tsk","_mk","_veh"]; waitUntil {sleep 0.5; !(_mk in allMapMarkers)}; [_mk] call BIS_fnc_deleteTask; }; }; }; _mks = allMapMarkers; }; }; }; }]; Place some "objective" markers to make it work. Share this post Link to post Share on other sites
killzone_kid 1326 Posted August 14, 2017 4 minutes ago, pierremgi said: As GOM said, a global variable could be the solution, but not discriminative on my tasks/markers so far. This is not what GOM said. You can make the variable global or even cosmic if you want, but it will still be undefined because task reference returned AFTER the task is created not before or during. Share this post Link to post Share on other sites
pierremgi 4739 Posted August 14, 2017 28 minutes ago, killzone_kid said: This is not what GOM said. You can make the variable global or even cosmic if you want, but it will still be undefined because task reference returned AFTER the task is created not before or during. Not exactly, sorry, I give you the full code. At least my variable _mk or missionNameSpace setVariable ["mk",...] were defined in several tests I made. It's not an undefined variable question at the moment I'm using the variable. I tested your solution also. And, don't worry, I know your skill and your personality, but regardless of this fact, you can place an undefined global variable in the code expression, this variable has just to be defined when you are running this code. Just test: add a line: blabla = "Cosmic variable"; // after the bis_fnc_setTask refer to blabla inside the code: "<execute expression='hint str [blabla] '>Cancel task</execute>" No error and working fine. (tested) This code is a string code after all, probably like compile code. Share this post Link to post Share on other sites
pierremgi 4739 Posted August 15, 2017 In other words, I'm still looking for command/function/script able to return the selected task. I can script something with currentTask but it's not the objective. I want the selected task (changing icon color and displaying the description). I tried something with ctrl 1001 1002 1003 IDCs , as task control tree, but I don't know how to pick the selected task with the index of idc 1002. _____________________________ found: "<execute expression=' deleteMarker ((player call bis_fnc_tasksUnit) select (lbCurSel (findDisplay 12 displayCtrl 1002)))'>Erase task</execute>" working only in the context of the given script above. Share this post Link to post Share on other sites
Muzzleflash 111 Posted August 18, 2017 You supply the ID in the first argument when you create the task (call _setTask)—so you already know it, just have to embed it in the string. Share this post Link to post Share on other sites
pierremgi 4739 Posted August 18, 2017 3 hours ago, Muzzleflash said: You supply the ID in the first argument when you create the task (call _setTask)—so you already know it, just have to embed it in the string. Some working example? Share this post Link to post Share on other sites
Muzzleflash 111 Posted August 18, 2017 Here is an example: My_DeleteTask = { params ["_taskId"]; [_taskId] call BIS_fnc_deleteTask; }; private _id = "TID_DestroyIslandBase"; private _desc = format ["You must destroy the enemy base on this island. Or, if you are lazy, you can choose not to do it by clicking <execute expression='[""%1""] call My_DeleteTask'>here</execute>.", _id]; private _title = "Destroy Base"; [_id, true, [_desc, _title], (getPos player) getPos [1000, random 360], "ASSIGNED", 5, true, true] call BIS_fnc_setTask; Share this post Link to post Share on other sites
pierremgi 4739 Posted August 18, 2017 Yes but that doesn't work for my purpose: deleting the selected task among some others. Thanks any way. I posted my solution, probably not the best one, but not so bad. Share this post Link to post Share on other sites
Muzzleflash 111 Posted August 18, 2017 Must admit don't really see why it would not work for your situation. Your solution seems overly complicated with the GUI hack, whereas mine would just have you embed the id. For example: + (format ["<execute expression='[""%1"", 0] call fn_tsk'>Delete task</execute>", _mk]) But if your works fine, then all is well that ends well. Not sure but it looks like if I make an a marker with the text, say "Amber Fall" or something, but makes it in group channel, fn_tsk, may get confused, because the description you search in with 'find' has both _tgtText and _mkText. Share this post Link to post Share on other sites
pierremgi 4739 Posted August 18, 2017 49 minutes ago, Muzzleflash said: Not sure but it looks like if I make an a marker with the text, say "Amber Fall" or something, but makes it in group channel, fn_tsk, may get confused, because the description you search in with 'find' has both _tgtText and _mkText. Yep, I understand what you mean. My final text description for the task is made with both initial marker text (_mkText) and an added text reminding the channel (task for your group!, task for our camp!..) So, indeed, if someone writes , say "defend our camp!" within marker text and decide to broadcast the marker/task on the group only, as far as the string "camp!" will be find in the description, the task will apply to the whole side if Go go go link is clicked. No impact for deletion of the task. Bah, It seems to me a little bit difficult to avoid that. I can change the string for something less usual... Thanks for this fine remark. Share this post Link to post Share on other sites