Hello people! I need some help with my project cause after all the research i have done i still feel lost in the space.

I have an emco5 cnc lathe. I am controlling 2 stepper motors through mach3 and a BOB for X-Z axis. My tool turret changer is being controlled through a dc motor and my arduino. Now i want to make the exact thing: to control my tool turret changer with my arduino through mach. I have found out a way through modBus. I have succeed in making mach3 and my arduino to talk to each other through some tutorials i found here on the forum. But how i will tell to my arduino to do this(change tool) when you see this M6 T0101in g-code? I am thinking that i have to do it somehow through the modBus and brains or through a macro.
P.S.1 I am not sure if the info i have provided are enough i am totally new at both arduino and mach3.
P.S.2 Excuse me for my english but it's not my native/mother language.
Thanks in advance people!

Constantine