# HG changeset patch # User nemo # Date 1293037175 18000 # Node ID b5d726bc4f8df0d9018f949ea5c28bb1d10224d2 # Parent b28516c13c05510035069f64a5b9a831a4e8daf7 FindPlace in lua now returns null for failure to find a place, and accepts a 5th parameter to try finding a place without considering proximity (note that this can place a gear right next to mines). diff -r b28516c13c05 -r b5d726bc4f8d hedgewars/uScript.pas --- 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;