This is an
extremely experimental hack, but should provide the effect you want.
Lua Code:
if select(2,UnitClass("player"))~="DRUID" then return; end-- Don't run if not a druid
local WatchFrame=CreateFrame("Frame",nil,nil,"SecureHandlerStateTemplate");-- Create State Driver
WatchFrame:SetFrameRef("StanceButton",StanceButton3);-- Link StanceButton3
WatchFrame:SetAttribute("_onstate-form","self:GetFrameRef('StanceButton'):SetID(newstate)");-- Set ID of StanceButton to whatever 'form' state is set to
RegisterStateDriver(WatchFrame,"form","[indoors] 2; 3");-- Register 'form' state to swap when we go indoors/outdoors
The action and stance bars don't use the
SecureActionButtonTemplate, so they can't be reconfigured to run custom macros without using up macro slots. The stance bar being non-configurable at all in that respect. The code I posted exploits the fact the stance buttons'
OnClick handler references each button's ID, so that's manipulated to toggle which form is used. This is done with secure code and a state driver to make sure taint isn't an issue.
Notes:
- The button texture doesn't change to reflect which form is configured. This is because only the
OnClick handler references the button's ID, not the update function. This could be fixed with more code, but at this point, it's just a proof of concept.
- The client and server briefly argue indoors/outdoors when transitioning between them. Be sure to allow a few seconds to pass before activating the button.