fix key binds for lua created teams and added wind control
authorHenek
Sun, 21 Nov 2010 16:48:44 +0100
changeset 4399 87bc4a9e6ef0
parent 4398 36d7e4b6ca81
child 4400 b190572290a0
fix key binds for lua created teams and added wind control
hedgewars/uScript.pas
--- a/hedgewars/uScript.pas	Sun Nov 21 17:48:58 2010 +0300
+++ b/hedgewars/uScript.pas	Sun Nov 21 16:48:44 2010 +0100
@@ -56,6 +56,7 @@
     uCommands,
     uUtils,
     uIO,
+    uKeys,
     uCaptions;
 
 var luaState : Plua_State;
@@ -824,6 +825,21 @@
         end;
     lc_getrandom:= 1
 end;
+
+function lc_setwind(L : Plua_State) : LongInt; Cdecl;
+begin
+    if lua_gettop(L) <> 1 then
+        LuaError('Lua: Wrong number of parameters passed to SetWind!')
+    else
+        begin
+        cWindSpeed:= int2hwfloat(lua_tointeger(L, 1)) / 100 * cMaxWindSpeed;
+        cWindSpeedf:= SignAs(cWindSpeed,cWindSpeed).QWordValue / SignAs(_1,_1).QWordValue;
+        if cWindSpeed.isNegative then
+            CWindSpeedf := -cWindSpeedf;
+        AddGear(0, 0, gtATSmoothWindCh, 0, _0, _0, 1)^.Tag:= hwRound(cWindSpeed * 72 / cMaxWindSpeed);
+        end;
+    lc_setwind:= 0
+end;
 ///////////////////
 
 procedure ScriptPrintStack;
@@ -1214,6 +1230,7 @@
 lua_register(luaState, 'GetGearMessage', @lc_getgearmessage);
 lua_register(luaState, 'SetGearMessage', @lc_setgearmessage);
 lua_register(luaState, 'GetRandom', @lc_getrandom);
+lua_register(luaState, 'SetWind', @lc_setwind);
 
 
 ScriptClearStack; // just to be sure stack is empty