hedgewars/uScript.pas
changeset 4629 b5d726bc4f8d
parent 4590 d9fed5a816e9
child 4682 0fc1ff341482
equal deleted inserted replaced
4628:b28516c13c05 4629:b5d726bc4f8d
   825 end;
   825 end;
   826 
   826 
   827 function lc_findplace(L : Plua_State) : LongInt; Cdecl;
   827 function lc_findplace(L : Plua_State) : LongInt; Cdecl;
   828 var gear: PGear;
   828 var gear: PGear;
   829     fall: boolean;
   829     fall: boolean;
       
   830     tryhard: boolean;
   830     left, right: LongInt;
   831     left, right: LongInt;
   831 begin
   832 begin
   832     if lua_gettop(L) <> 4 then
   833     tryhard:= false;
       
   834     if (lua_gettop(L) <> 4) and (lua_gettop(L) <> 5) then
   833         LuaError('Lua: Wrong number of parameters passed to FindPlace!')
   835         LuaError('Lua: Wrong number of parameters passed to FindPlace!')
   834     else
   836     else
   835         begin
   837         begin
   836         gear:= GearByUID(lua_tointeger(L, 1));
   838         gear:= GearByUID(lua_tointeger(L, 1));
   837         fall:= lua_toboolean(L, 2);
   839         fall:= lua_toboolean(L, 2);
   838         left:= lua_tointeger(L, 3);
   840         left:= lua_tointeger(L, 3);
   839         right:= lua_tointeger(L, 4);
   841         right:= lua_tointeger(L, 4);
   840         if gear <> nil then
   842         if lua_gettop(L) = 5 then tryhard:= lua_toboolean(L, 5);
   841             FindPlace(gear, fall, left, right)
   843         if gear <> nil then
   842         end;
   844             FindPlace(gear, fall, left, right, tryhard);
   843     lc_findplace:= 0
   845         if gear <> nil then lua_pushinteger(L, gear^.uid)
       
   846         else lua_pushnil(L);
       
   847         end;
       
   848     lc_findplace:= 1
   844 end;
   849 end;
   845 
   850 
   846 function lc_playsound(L : Plua_State) : LongInt; Cdecl;
   851 function lc_playsound(L : Plua_State) : LongInt; Cdecl;
   847 var gear: PGear;
   852 var gear: PGear;
   848 begin
   853 begin