Just like that really...
In a function as long as the variable was declared you could just type what you just did...

function WhatHaveYou()
{
...... // some code
xVar = my.x,
xVar = my.y;
etc.
...... // more code
}

If I may direct you to AUM 59 you can read the workshop about weapons using c_trace which should help immensely in your transporter idea. I'm a terrible coder and I've already figured out a way to acclomplish that