hedgewars/uScript.pas
changeset 12930 330b6c353093
parent 12929 1d7d7d21914a
child 12931 c27dd59a3ffe
--- a/hedgewars/uScript.pas	Thu Feb 08 18:42:07 2018 +0100
+++ b/hedgewars/uScript.pas	Thu Feb 08 19:02:51 2018 +0100
@@ -2387,6 +2387,23 @@
     lc_setwind:= 0
 end;
 
+function lc_getwind(L : Plua_State) : LongInt; Cdecl;
+var wind: extended;
+begin
+    if CheckLuaParamCount(L, 0, 'GetWind', '') then
+        begin
+        wind:= hwFloat2float((cWindSpeed / cMaxWindSpeed) * 100);
+        if wind < -100 then
+            wind:= -100
+        else if wind > 100 then
+            wind:= 100;
+        lua_pushnumber(L, wind);
+        end
+    else
+        lua_pushnil(L);
+    lc_getwind:= 1
+end;
+
 function lc_maphasborder(L : Plua_State) : LongInt; Cdecl;
 begin
     if CheckLuaParamCount(L, 0, 'MapHasBorder', '') then
@@ -3674,6 +3691,7 @@
 lua_register(luaState, _P'SetGearCollisionMask', @lc_setgearcollisionmask);
 lua_register(luaState, _P'GetRandom', @lc_getrandom);
 lua_register(luaState, _P'SetWind', @lc_setwind);
+lua_register(luaState, _P'GetWind', @lc_getwind);
 lua_register(luaState, _P'MapHasBorder', @lc_maphasborder);
 lua_register(luaState, _P'GetHogHat', @lc_gethoghat);
 lua_register(luaState, _P'SetHogHat', @lc_sethoghat);