This is a parse order problem. Standard global variables are pretty much the last things that are translated. So when your addon is executed you only get the variables.
So you gotta figure that out yourself in the addon. Maybe this is helpful.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.