# HG changeset patch # User Wuzzy # Date 1518147447 -3600 # Node ID c27dd59a3ffe89bcd15dadbf836af8afe3696752 # Parent 330b6c3530933ba63add61c83d96bbf175e63929 Lua API: Add GetTeamName diff -r 330b6c353093 -r c27dd59a3ffe ChangeLog.txt --- a/ChangeLog.txt Thu Feb 08 19:02:51 2018 +0100 +++ b/ChangeLog.txt Fri Feb 09 04:37:27 2018 +0100 @@ -32,6 +32,7 @@ + New call: SetVampiric(bool): Toggle vampirism + New call: SetLaserSight(bool): Toggle laser sight + New call: GetWind(): Returns current wind (approximation) from -100 to 100 + + New call: GetTeamName(teamIdx): Returns name of team with given index (starts at 0) + New callback: onEndTurn(): Called at the end of a turn (when gears have settled) * Fix call: SetWeapon(amNothing) now unselects weapon * Fix global: TotalRounds was stuck at -1 for several turns diff -r 330b6c353093 -r c27dd59a3ffe hedgewars/uScript.pas --- a/hedgewars/uScript.pas Thu Feb 08 19:02:51 2018 +0100 +++ b/hedgewars/uScript.pas Fri Feb 09 04:37:27 2018 +0100 @@ -2051,6 +2051,22 @@ lc_addteam:= 0;//1; end; +function lc_getteamname(L : Plua_State) : LongInt; Cdecl; +var t: LongInt; +begin + if CheckLuaParamCount(L, 1, 'GetTeamName', 'teamIdx') then + begin + t:= Trunc(lua_tonumber(L, 1)); + if (t < 0) or (t >= TeamsCount) then + lua_pushnil(L) + else + lua_pushstring(L, str2pchar(TeamsArray[t]^.TeamName)); + end + else + lua_pushnil(L); + lc_getteamname:= 1; +end; + function lc_dismissteam(L : Plua_State) : LongInt; Cdecl; var HHGear: PGear; i, h : LongInt; @@ -3636,6 +3652,7 @@ lua_register(luaState, _P'SetAmmo', @lc_setammo); lua_register(luaState, _P'SetAmmoDelay', @lc_setammodelay); lua_register(luaState, _P'PlaySound', @lc_playsound); +lua_register(luaState, _P'GetTeamName', @lc_getteamname); lua_register(luaState, _P'AddTeam', @lc_addteam); lua_register(luaState, _P'AddHog', @lc_addhog); lua_register(luaState, _P'AddAmmo', @lc_addammo);