132 |
132 |
133 || *Identifier* || *Meaning* || |
133 || *Identifier* || *Meaning* || |
134 || `lfIce` || Slippery terrain, hogs will slide on it. || |
134 || `lfIce` || Slippery terrain, hogs will slide on it. || |
135 || `lfBouncy` || Bouncy terrain, hogs and some other gears will bounce off when they collide with it. || |
135 || `lfBouncy` || Bouncy terrain, hogs and some other gears will bounce off when they collide with it. || |
136 || `lfIndestructible` || Almost indestructible terrain, most weapons will not destroy it. || |
136 || `lfIndestructible` || Almost indestructible terrain, most weapons will not destroy it. || |
137 || `lfNormal` || Normal destroyable terrain. Note that this is only actually the case when no other land flag is set. || |
137 || `0` || Normal destroyable terrain. Note that this is the case when no other land flag is set. || |
138 |
138 |
139 === More constants === |
139 === More constants === |
140 More constants are at at [GearTypes Gear Types] , [AmmoTypes Ammo Types], [Sounds], [States], [Sprites], [VisualGearTypes Visual Gear Types]. |
140 More constants are at at [GearTypes Gear Types] , [AmmoTypes Ammo Types], [Sounds], [States], [Sprites], [VisualGearTypes Visual Gear Types]. |
141 |
141 |
142 == Event handlers == |
142 == Event handlers == |
775 |
775 |
776 === `SetGearCollisionMask(gearUid, mask)` === |
776 === `SetGearCollisionMask(gearUid, mask)` === |
777 Set the collision mask of the given gear with `gearUid`. |
777 Set the collision mask of the given gear with `gearUid`. |
778 The collision mask defines with which gears and terrain types the gear can collide. |
778 The collision mask defines with which gears and terrain types the gear can collide. |
779 |
779 |
780 `mask` is a number between `0x0000` and `0xFFFF` and used as a bitfield. The following flags are available (excerpt): |
780 `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): |
781 |
781 |
782 || *Flag* || *Effect* || |
782 || *Flag* || *Collision with …* || |
783 || `0xFF00` || Terrain || |
783 || `0xFF00` || Terrain || |
784 || `0x0080` || Current hedgehog || |
784 || `0x0080` || Current hedgehog and crates || |
785 || `0x000F` || Other hedgehogs || |
785 || `0x000F` || Other hedgehogs || |
786 || `0x0070` || Mines and explosives || |
786 || `0x0070` || Mines and explosives || |
787 |
787 |
788 Beware, the collision mask is often set by the engine as well. |
788 Beware, the collision mask is often set by the engine as well. |
789 |
789 |
790 Example: |
790 Examples: |
791 ``` |
791 ``` |
792 SetGearCollisionMask(gear, 0xFF7F) |
792 SetGearCollisionMask(gear, 0xFF7F) |
793 -- Ignore collision with current hedgehog |
793 -- Ignore collision with current hedgehog |
794 ``` |
794 ``` |
795 |
795 |
796 The full range of flags can be found in the engine source code (in Pascal): |
796 ``` |
|
797 SetGearCollisionMask(gear, 0xFFFF) |
|
798 -- Collide with everything |
|
799 ``` |
|
800 |
|
801 ``` |
|
802 SetGearCollisionMask(gear, 0x00FF) |
|
803 -- Collide with hedgehogs and objects |
|
804 ``` |
|
805 |
|
806 ``` |
|
807 SetGearCollisionMask(gear, 0x0000) |
|
808 -- Collide with nothing |
|
809 ``` |
|
810 |
|
811 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): |
797 https://hg.hedgewars.org/hedgewars/file/default/hedgewars/uConsts.pas#l112 |
812 https://hg.hedgewars.org/hedgewars/file/default/hedgewars/uConsts.pas#l112 |
798 |
813 |
799 === `GetGearCollisionMask(gearUid)` === |
814 === `GetGearCollisionMask(gearUid)` === |
800 Returns the current collision mask of the given gear. See `SetGearCollisionMask` for an explanation of the mask. |
815 Returns the current collision mask of the given gear. See `SetGearCollisionMask` for an explanation of the mask. |
801 |
816 |