# HG changeset patch # User Wuzzy # Date 1519136617 0 # Node ID edda2e2b973f6ec6e9bb3ccf895a6ace3c1d9831 # Parent 971427650f1f212f5db4ab2137a57d477e8d53fe LuaAPI: Add SetGearCollisionMask and GetGearCollisionMask diff -r 971427650f1f -r edda2e2b973f LuaAPI.wiki --- a/LuaAPI.wiki Tue Feb 20 13:55:00 2018 +0000 +++ b/LuaAPI.wiki Tue Feb 20 14:23:37 2018 +0000 @@ -773,6 +773,32 @@ === !SetGearPosition(gearUid, x, y) === Places the specified gear exactly at the position (`x`,`y`). Not to be confused with `SetGearPos`. +=== `SetGearCollisionMask(gearUid, mask)` === +Set the collision mask of the given gear with `gearUid`. +The collision mask defines with which gears and terrain types the gear can collide. + +`mask` is a number between `0x0000` and `0xFFFF` and used as a bitfield. The following flags are available (excerpt): + +|| *Flag* || *Effect* || +|| `0xFF00` || Terrain || +|| `0x0080` || Current hedgehog || +|| `0x000F` || Other hedgehogs || +|| `0x0070` || Mines and explosives || + +Beware, the collision mask is often set by the engine as well. + +Example: +``` +SetGearCollisionMask(gear, 0xFF7F) +-- Ignore collision with current hedgehog +``` + +The full range of flags can be found in the engine source code (in Pascal): +https://hg.hedgewars.org/hedgewars/file/default/hedgewars/uConsts.pas#l112 + +=== `GetGearCollisionMask(gearUid)` === +Returns the current collision mask of the given gear. See `SetGearCollisionMask` for an explanation of the mask. + === !SetGearVelocity(gearUid, dx, dy) === Gives the specified gear the velocity of `dx`, `dy`.