# HG changeset patch # User sheepluva # Date 1441147175 -7200 # Node ID b91667fd6f2019c2f4030552fd4ec3b7aa879aaf # Parent adb5ef54da5419c750df1d41f426328c71681bbf Lua API: SetMaxBuildDistance([ distInPx ]) -- set to 0 for no limit; call with no param to reset to default diff -r adb5ef54da54 -r b91667fd6f20 hedgewars/uConsts.pas --- a/hedgewars/uConsts.pas Tue Sep 01 23:54:13 2015 +0200 +++ b/hedgewars/uConsts.pas Wed Sep 02 00:39:35 2015 +0200 @@ -171,6 +171,8 @@ cFontBorder = 2; + cDefaultBuildMaxDist = 256; + // do not change this value cDefaultZoomLevel = 2.0; diff -r adb5ef54da54 -r b91667fd6f20 hedgewars/uScript.pas --- a/hedgewars/uScript.pas Tue Sep 01 23:54:13 2015 +0200 +++ b/hedgewars/uScript.pas Wed Sep 02 00:39:35 2015 +0200 @@ -440,6 +440,26 @@ lc_setweapon:= 0; end; +// no parameter means reset to default (and 0 means unlimited) +function lc_setmaxbuilddistance(L : Plua_State) : LongInt; Cdecl; +var np: LongInt; +const + call = 'SetMaxBuildDistance'; + params = '[ distInPx ]'; +begin + if CheckAndFetchParamCountRange(L, 0, 1, call, params, np) then + begin + if np = 0 then + begin + // no args? reset + cBuildMaxDist:= cDefaultBuildMaxDist; + end + else + CBuildMaxDist:= lua_tointeger(L, 1); + end; + lc_setmaxbuilddistance:= 0; +end; + // sets weapon to whatever weapons is next (wraps around, amSkip is skipped) function lc_setnextweapon(L : Plua_State) : LongInt; Cdecl; var at : LongInt; @@ -3301,6 +3321,7 @@ lua_register(luaState, _P'SetWaterLine', @lc_setwaterline); lua_register(luaState, _P'SetNextWeapon', @lc_setnextweapon); lua_register(luaState, _P'SetWeapon', @lc_setweapon); +lua_register(luaState, _P'SetMaxBuildDistance', @lc_setmaxbuilddistance); // drawn map functions lua_register(luaState, _P'AddPoint', @lc_addPoint); lua_register(luaState, _P'FlushPoints', @lc_flushPoints); diff -r adb5ef54da54 -r b91667fd6f20 hedgewars/uVariables.pas --- a/hedgewars/uVariables.pas Tue Sep 01 23:54:13 2015 +0200 +++ b/hedgewars/uVariables.pas Wed Sep 02 00:39:35 2015 +0200 @@ -2566,7 +2566,7 @@ cElastic := _0_9; cGravity := cMaxWindSpeed * 2; cGravityf := 0.00025 * 2; - cBuildMaxDist := 256; + cBuildMaxDist := cDefaultBuildMaxDist; cDamageModifier := _1; TargetPoint := cTargetPointRef;