add a script function to remove a unit from the map

This commit is contained in:
Tim Felgentreff 2015-09-02 12:09:26 +02:00
parent 817cfb64f6
commit b9ac622b74

View file

@ -631,6 +631,24 @@ static int CclMoveUnit(lua_State *l)
return 1;
}
/**
** Remove unit from the map.
**
** @param l Lua state.
**
** @return Returns 1.
*/
static int CclRemoveUnit(lua_State *l)
{
LuaCheckArgs(l, 1);
lua_pushvalue(l, 1);
CUnit *unit = CclGetUnit(l);
lua_pop(l, 1);
unit->Remove(NULL);
lua_pushvalue(l, 1);
return 1;
}
/**
** Create a unit and place it on the map
**
@ -1172,6 +1190,7 @@ void UnitCclRegister()
lua_register(Lua, "Unit", CclUnit);
lua_register(Lua, "MoveUnit", CclMoveUnit);
lua_register(Lua, "RemoveUnit", CclRemoveUnit);
lua_register(Lua, "CreateUnit", CclCreateUnit);
lua_register(Lua, "DamageUnit", CclDamageUnit);
lua_register(Lua, "SetResourcesHeld", CclSetResourcesHeld);