Index
Unit

CreateUnitOnTerrain

CreateUnitOnTerrain(<-CmodUID <-cellX <-cellZ <-initParams) ->unitUID

Description

Creates a unit from a CMOD UID (GUID)1) or from an internal unit name2).

initParams is a table that contains a set of variables that will be set on the newly created unit. See GetUnitSettings for a list of the data names that can be specified in the initData table when creating built in units.

The unit will be placed on the terrain at the supplied terrain cell coordinates. The lower left corner of the map is 0,0 (0:0) and the top right is mapWidth,mapLength. The unit will be placed at a height (the Y position) based on the terrain height at the specified coordinates.

The unit UID will be pushed to the stack. If the unit can not be created, -1 is pushed to the stack. See CreateUnit for more details.

Examples

"abcdefgh1234567" ->cmodUID
CreateUnitOnTerrain(<-cmodUID 42 23 0) ->unitUID

See Also

Index

1)
You can get the GUID from within the CPACK manager. GUIDs are unique to each custom unit and never change.
2)
See UnitTypes for a list of these names.