Luft08 27 Posted October 17, 2021 I'm looking to improve my code that checks to see if a group's knowledge of the players changes. Right now I use code that I repeatedly call using the BIS_fnc_loop function. I was hoping there would be an event handler which would be more efficient but I don't see it. Thanks. Share this post Link to post Share on other sites
Ibragim A 148 Posted October 17, 2021 5 hours ago, Luft08 said: I'm looking to improve my code that checks to see if a group's knowledge of the players changes. Right now I use code that I repeatedly call using the BIS_fnc_loop function. I was hoping there would be an event handler which would be more efficient but I don't see it. Thanks. fn_knowsabout_handler = { params ["_target", "_who", "_wait"]; while {true} do { private _knowsAbout = _who knowsAbout _target; waitUntil { sleep _wait; if (_who knowsAbout _target isNotEqualTo _knowsAbout) exitWith { /// Code block on change: systemchat format ["%1 knowsAbout %2 value changed from %3 to %4", _who, _target, _knowsAbout, (_who knowsAbout _target)]; }; }; }; }; [player, somegroup, 0.5] spawn fn_knowsabout_handler; 1 Share this post Link to post Share on other sites
.kju 3240 Posted October 18, 2021 Made a FT request based on Dedmen's advice: https://feedback.bistudio.com/T161515 2 Share this post Link to post Share on other sites
Luft08 27 Posted October 18, 2021 On 10/17/2021 at 3:13 AM, Ibragim A said: fn_knowsabout_handler = { params ["_target", "_who", "_wait"]; while {true} do { private _knowsAbout = _who knowsAbout _target; waitUntil { sleep _wait; if (_who knowsAbout _target isNotEqualTo _knowsAbout) exitWith { /// Code block on change: systemchat format ["%1 knowsAbout %2 value changed from %3 to %4", _who, _target, _knowsAbout, (_who knowsAbout _target)]; }; }; }; }; [player, somegroup, 0.5] spawn fn_knowsabout_handler; Thanks Ibragim A. I think the take away here is that there isn't an existing event handler to do what I want. But maybe I can add my own using addMissionEventHandler. I'll look over your code to see if it is more efficient than mine and if it can be used in a custom event handler. (Assuming that addMissionEventHandler does what I hope it does.) Never mind. ☹️ I was excited but alas my hopes have been crushed. The addMissionEventHandlers are preexisting handlers attached to the mission. Not much hope in using them. Maybe I need to look at the code that the Eden editor uses for triggers? Share this post Link to post Share on other sites
pierremgi 4740 Posted October 18, 2021 Triggers (repeatable) are also loops. If an event handler doesn't exist, you can use scripted loops, or generic onEachFrame EH with drastic conditions. Triggers and loops are working fine. You can set the loop (and now trigger) interval. And you can decide extra conditions like knowsAbout changes. I suggest you to set a threshold for any changing value: here knowsabout can evolve from 0 to 4 and it's useless to "react" for all changes: 0.541, 0.687,... 1.488... 4. Imho the interesting threshold is 1.5. 3 Share this post Link to post Share on other sites
Luft08 27 Posted October 18, 2021 38 minutes ago, pierremgi said: Triggers (repeatable) are also loops. If an event handler doesn't exist, you can use scripted loops, or generic onEachFrame EH with drastic conditions. Triggers and loops are working fine. You can set the loop (and now trigger) interval. And you can decide extra conditions like knowsAbout changes. I suggest you to set a threshold for any changing value: here knowsabout can evolve from 0 to 4 and it's useless to "react" for all changes: 0.541, 0.687,... 1.488... 4. Imho the interesting threshold is 1.5. Out of curiosity what makes 1.5 interesting? Is that the value that something happens? 1 Share this post Link to post Share on other sites
pierremgi 4740 Posted October 18, 2021 See notes. 1 Share this post Link to post Share on other sites