SetBit

From GECK

A function added by the New Vegas Script Extender.

Description

Returns the specified int with the specified bit set to 1, or optionally 0 (cleared). This function is useful for manipulating bitmasks.

Syntax

(int) SetBit Target:int BitToSet:int NewBitValue:bool

Example

int a
set a to 11		; bits 0, 1, 3 set
set a to SetBit a, 2	; sets bit 2 (value 4)
; a is now 15
set a to SetBit a, 1, 0	; would set bit 1 (value 2), but the third parameter is 0 so instead it clears the bit
; a is now 13

Notes

  • SetBit considers the first bit be numbered, 0, and the final bit to be 31; however, it should not be used to change bits greater than 29 to avoid sign and float conversion issues.

See Also

Personal tools