bit/bor

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
m (Also menu state)
Line 3: Line 3:
 
|Realm=Shared and Menu
 
|Realm=Shared and Menu
 
|IsClass=No
 
|IsClass=No
|Name=bor
 
|Parent=bit
 
 
}}
 
}}
 
{{Arg
 
{{Arg
Line 35: Line 33:
 
}}
 
}}
 
{{Example
 
{{Example
|Description=If you were to add capabilities to an NPC.
+
|Description=If you want to add multiple capabilities to a NPC, use [https://wiki.garrysmod.com/index.php?title=bit/bor bit.bor]:
 
|Code=NPC:CapabilitiesAdd( bit.bor(CAP_MOVE_GROUND, CAP_ANIMATEDFACE, CAP_TURN_HEAD) )
 
|Code=NPC:CapabilitiesAdd( bit.bor(CAP_MOVE_GROUND, CAP_ANIMATEDFACE, CAP_TURN_HEAD) )
 
}}
 
}}

Revision as of 13:02, 5 February 2019

 bit.bor( )

Contents

Description

Returns the bitwise OR of all values specified.

Arguments

number value1

The first value.

Arguments

vararg ...

Extra values to be evaluated. (must all be numbers)

Returns

number

The bitwise OR result between all numbers.

Examples

Example

Performs the bitwise OR operation between three values

local a = math.BinToInt("1000")
local b = math.BinToInt("0100")
local c = math.BinToInt("0001")

local result = bit.bor(a, b, c)

print(math.IntToBin(result))
print(result)

Output:


1101

13

Examples

Example

If you want to add multiple capabilities to a NPC, use bit.bor:

NPC:CapabilitiesAdd( bit.bor(CAP_MOVE_GROUND, CAP_ANIMATEDFACE, CAP_TURN_HEAD) )


Personal tools
Navigation