expose a function to trigger a unit transformation from a script
This commit is contained in:
parent
b9ac622b74
commit
b8a4a7c43d
1 changed files with 21 additions and 0 deletions
|
@ -703,6 +703,26 @@ static int CclCreateUnit(lua_State *l)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** 'Upgrade' a unit in place to a unit of different type.
|
||||
**
|
||||
** @param l Lua state.
|
||||
**
|
||||
** @return Returns success.
|
||||
*/
|
||||
static int CclTransformUnit(lua_State *l)
|
||||
{
|
||||
lua_pushvalue(l, 1);
|
||||
CUnit *targetUnit = CclGetUnit(l);
|
||||
lua_pop(l, 1);
|
||||
lua_pushvalue(l, 2);
|
||||
const CUnitType *unittype = TriggerGetUnitType(l);
|
||||
lua_pop(l, 1);
|
||||
CommandUpgradeTo(*targetUnit, *(CUnitType*)unittype, 1);
|
||||
lua_pushvalue(l, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
** Damages unit, additionally using another unit as first's attacker
|
||||
**
|
||||
|
@ -1192,6 +1212,7 @@ void UnitCclRegister()
|
|||
lua_register(Lua, "MoveUnit", CclMoveUnit);
|
||||
lua_register(Lua, "RemoveUnit", CclRemoveUnit);
|
||||
lua_register(Lua, "CreateUnit", CclCreateUnit);
|
||||
lua_register(Lua, "TransformUnit", CclTransformUnit);
|
||||
lua_register(Lua, "DamageUnit", CclDamageUnit);
|
||||
lua_register(Lua, "SetResourcesHeld", CclSetResourcesHeld);
|
||||
lua_register(Lua, "SetTeleportDestination", CclSetTeleportDestination);
|
||||
|
|
Loading…
Reference in a new issue