hedgewars/uScript.pas
changeset 4629 b5d726bc4f8d
parent 4590 d9fed5a816e9
child 4682 0fc1ff341482
--- a/hedgewars/uScript.pas	Wed Dec 22 10:09:39 2010 -0500
+++ b/hedgewars/uScript.pas	Wed Dec 22 11:59:35 2010 -0500
@@ -827,9 +827,11 @@
 function lc_findplace(L : Plua_State) : LongInt; Cdecl;
 var gear: PGear;
     fall: boolean;
+    tryhard: boolean;
     left, right: LongInt;
 begin
-    if lua_gettop(L) <> 4 then
+    tryhard:= false;
+    if (lua_gettop(L) <> 4) and (lua_gettop(L) <> 5) then
         LuaError('Lua: Wrong number of parameters passed to FindPlace!')
     else
         begin
@@ -837,10 +839,13 @@
         fall:= lua_toboolean(L, 2);
         left:= lua_tointeger(L, 3);
         right:= lua_tointeger(L, 4);
+        if lua_gettop(L) = 5 then tryhard:= lua_toboolean(L, 5);
         if gear <> nil then
-            FindPlace(gear, fall, left, right)
+            FindPlace(gear, fall, left, right, tryhard);
+        if gear <> nil then lua_pushinteger(L, gear^.uid)
+        else lua_pushnil(L);
         end;
-    lc_findplace:= 0
+    lc_findplace:= 1
 end;
 
 function lc_playsound(L : Plua_State) : LongInt; Cdecl;