How can I assign variable to another variable name? for example, I would like to achieve the following
function ballPosition(ballType)
balls[ball].ballType.x = balls[ball].x
balls[ball].ballType.y = balls[ball].y
end
if balls[ball].type == "fireBall" then
ballPosition(fireBall)
elseif balls[ball].type == "powerLessBall" then
ballPosition(powerLessBall)
end
at the moment i have:
if balls[ball].type == "fireBall" then
balls[ball].fireBall.x = balls[ball].x
balls[ball].fireBall.y = balls[ball].y
elseif balls[ball].type == "powerLessBall" then
balls[ball].powerLessBall.x = balls[ball].x
balls[ball].powerLessBall.y = balls[ball].y
end