[LUA Question/Issue] How I do to make an entity spawn according to the entity's spawner angles?

Well, hello there. I know it might sound strange, but Im trying to make a soda machine for a… roleplaying gamemode.
The thing is, I know how to make a entity to spawn another entity when you press E, I adjusted the spawn position of the soda to appear infront of the machine, but the thing is, that when I rotate the machine, the soda appears out of place.
How I can set some kind of spawn pos according to another entity’s angles?

You want to use Entity:GetForward().

[lua]–Distance to spawn from base position
local fwdOffset = 20
local upOffset = -40
local rightOffset = 5

–Entities
local spawner = YourSodaMachine
local newent = YourSodaCan

–Get position and angles (actually ‘normal’ vectors)
local spawnerPos = spawner:GetPos()
local fwdDir = spawner:GetForward()
local upDir = spawner:GetUp()
local rightDir = spawner:GetRight()


local positionOffset = Vector( fwdDirfwdOffset, rightDirrightOffset, upDir*upOffset )
local newPos = spawnerPos + positionOffset
newent:SetPos(newPos)[/lua]

Same thing but compact:
[lua]newent:SetPos( spawner:GetPos() + Vector(spawner:GetForward()*20, spawner:GetRight()5, spawner:GetUp()-40) )[/lua]

Looks very good, I’ll try it later, and I’ll tell you if it works :3
Thanks anyways for this useful reply.

EDIT:
It doesn’t work, it spawns the soda can on the center of the entity.