Plugin For Switch Weapon

I wanna Some one Give me Code For Python Switch Staff Durability Low
char must now back to town and Fix and back to attack or chose (Change Primary weapon if broken ) but it’s not work in my game it every 2 sce change the same 2 weapon idk what is this so i create plugin in Ai Generator to do it with deferent way like i have 5 staff in my slot i wanna char when he botting change 5 slot staff to the last staff broken
Some Dev code to do it

Theres no useful code here, delete it all

ok, but i wanna some one create a code like i said there someone can do it !