Total War: WARHAMMER II

Total War: WARHAMMER II

ClickNFight or Spell easy access
paperpancake 8 Jun, 2020 @ 12:48pm
Fixing the incompatibility with Find Idle Units
I love your mod. :) Would you be willing to make a small change for better compatibility? Right now your mod uses this function:

bm:register_unit_selection_handler("ClickAndFight_UnitSelectionHandler")

I believe that function only allows one selection handler at a time, so it can interfere with other mods. To fix the incompatibility, you could choose one of these options:

  1. You could replace that line with the following code:
    do --The battle manager registers its own unit selection handler for some cases, --but it clears it out if there's not a registered callback. The following --do-block tells the battle manager to keep its selection handler: do local dummy_callback = { unit = nil, callback = function() --[[do nothing]] end; }; if #bm.unit_selection_callback_list == 0 then bm:register_unit_selection_handler("battle_manager_unit_selection_handler"); end; table.insert(bm.unit_selection_callback_list, dummy_callback); end; --Now that we've made sure the battle manager's selection handler will work, --we override the old, global function that it uses so that we can --piggyback on its functionality --This way we can use the selection handler that already exists --without needing to add our own one that will interfere with the existing one. local original_handler = battle_manager_unit_selection_handler; battle_manager_unit_selection_handler = function(unit, is_selected) original_handler(unit, is_selected); --This is where you can call your own function, like this: ClickAndFight_UnitSelectionHandler(unit, is_selected); end; end;

  2. You could instead use bm:register_unit_selection_callback(unit subject unit, function callback)[chadvandy.github.io]. That will respond to only the unit you care about, but if you use this it would require more changes to your script, so I personally like the first option in your case.

Feel free to reply if you have any questions or concerns. I've also sent you a Steam friend invite if you'd like to discuss more in private, or you can message me on Discord paperpancake5#2391
< >
Showing 1-2 of 2 comments
gabfou  [developer] 8 Jun, 2020 @ 4:16pm 
I will look into next time i have time Thanks for your explanation
gabfou  [developer] 8 Jun, 2020 @ 6:53pm 
It seems to work ok. Thanks for your code and your explanation mate!
< >
Showing 1-2 of 2 comments
Per page: 1530 50