[Advanced Modding] Unit Frame UI: how to get player-dependent commands?

I’m trying to mod autoharvest button for renewable resource nodes and I’d like the button to change icon depending on whether autoharvest is on or off like arrow button changes for the Archer based on arrow type. I examined the code for item swapping but I didn’t find anything what would change the command button to the next one. Could someone help me?

1 Like

The arrow button is kinda of complex.
What you can do that will look the same for players is just have multiple buttons, but the ones not in use be hidden. When you click on the active button, it hides it, run your code and unhide the next button.

Well, it works, but for my next idea (which I’d like to keep secret for a while) I need every player to get different set of commands based on their amenity towards the owner. My problem is I have no idea how exactly the UI works. If it is handled by the client (I guess so) then I’d have to make different commands displayed based on the session.player_id. I’d modify the commands component so except the current table (shown only by the owner) it has subtables for each amenity. My goal is: when I change the player ID via Lua console the UI command buttons change as well.

I have more basic question as well: is there a way to detect when an entity changes its form between placed and iconic? I need to disable autoharvest whenever an entity goes iconic but I don’t know how.

Out of curiosity: would harvest effect overlays, zone markings and unfinished buildings appear for just one player now or would everyone see them? I wonder how well is SH prepared for multiplayer.