# HG changeset patch # User Wuzzy # Date 1519136984 0 # Node ID 460d8f3aaf3216d14769708ee06aa04588e9c76c # Parent edda2e2b973f6ec6e9bb3ccf895a6ace3c1d9831 LuaAPI: Rewrite SetGearCollisionMask diff -r edda2e2b973f -r 460d8f3aaf32 LuaAPI.wiki --- a/LuaAPI.wiki Tue Feb 20 14:23:37 2018 +0000 +++ b/LuaAPI.wiki Tue Feb 20 14:29:44 2018 +0000 @@ -134,7 +134,7 @@ || `lfIce` || Slippery terrain, hogs will slide on it. || || `lfBouncy` || Bouncy terrain, hogs and some other gears will bounce off when they collide with it. || || `lfIndestructible` || Almost indestructible terrain, most weapons will not destroy it. || -|| `lfNormal` || Normal destroyable terrain. Note that this is only actually the case when no other land flag is set. || +|| `0` || Normal destroyable terrain. Note that this is the case when no other land flag is set. || === More constants === More constants are at at [GearTypes Gear Types] , [AmmoTypes Ammo Types], [Sounds], [States], [Sprites], [VisualGearTypes Visual Gear Types]. @@ -777,23 +777,38 @@ 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): +`mask` is a number between `0x0000` and `0xFFFF` and used as a bitfield, which means you can combine these flags with `bor`. These are the available flags (excerpt): -|| *Flag* || *Effect* || +|| *Flag* || *Collision with …* || || `0xFF00` || Terrain || -|| `0x0080` || Current hedgehog || +|| `0x0080` || Current hedgehog and crates || || `0x000F` || Other hedgehogs || || `0x0070` || Mines and explosives || Beware, the collision mask is often set by the engine as well. -Example: +Examples: ``` SetGearCollisionMask(gear, 0xFF7F) -- Ignore collision with current hedgehog ``` -The full range of flags can be found in the engine source code (in Pascal): +``` +SetGearCollisionMask(gear, 0xFFFF) +-- Collide with everything +``` + +``` +SetGearCollisionMask(gear, 0x00FF) +-- Collide with hedgehogs and objects +``` + +``` +SetGearCollisionMask(gear, 0x0000) +-- Collide with nothing +``` + +There are actual more flags availbable, but they are not as useful for use in Lua. You can find the full range of flags in the engine source code (in Pascal): https://hg.hedgewars.org/hedgewars/file/default/hedgewars/uConsts.pas#l112 === `GetGearCollisionMask(gearUid)` ===