Looking over the different lua functions reference, I see:
teleportUnit
civ.teleportUnit(unit, tile)
**I am kind of curious if it should really be civ.teleportUnit (unit, {tile})?
civ.teleportUnit(unit,tile) takes a unit object and a tile object. A tile object is different from a table that has three elements which we interpret as coordinates.
If we have
destination = {10,12,1}
then we use
civ.teleportUnit(myUnit,civ.getTile(destination[1],destination[2],destination[3]))
since we may do this a lot, we might define a function to make it quicker
function tableTile (myTile)
return civ.getTile(myTile[1],myTile[2],myTile[3])
end
**Though I'm not totally certain what "returns" completely means...
When a function returns a variable, that variable is then available for other computations. Let's evaluate in steps the following line
1. civ.teleportUnit(myUnit,civ.getTile(destination[1],destination[2],destination[3]))
destination[1] returns 10, destination[2] returns 12, destination[3] returns 1, for
2. civ.teleportUnit(myUnit,civ.getTile(10,12,1))
civ.getTile picks out the tile object in the game with coordinates 10,12,1, which we'll call destinationTile
3. civ.teleportUnit(myUnit,destinationTile)
This whole thing can be evaluated. It doesn't return anything, but does the game board action of moving the unit in question.
But what I'm thinking is that you could write some code that would basically check for a unit to enter one tile, and it would then automatically teleport it to another tile, and you could do this as many times as you wished in a turn.
Teleporting between turns is possible. To teleport in the middle of a turn would require an event trigger, such as a unit kill. The only event we have at the moment that can be triggered at will is the civ.scen.onLoad/civ.scen.onSave, which is a hassle.