int
From NWN Lexicon
Jump to navigationJump to search
A signed 32-bit number. This is an actual number without a decimal and can be negative. Maximum 2,147,483,647, minimum -2,147,483,648, default 0. If you overflow it will wrap around (ie: 2,147,483,647 + 1 = -2,147,483,648, -2,147,483,648 - 1 = 2,147,483,647).
There is no boolean value in nwscript. TRUE is defined as 1 and FALSE is defined as 0.
A number of Bitwise Operators work in nwscript, allowing integers to store a lot of true/false information much more efficiently.
Example
Some example bitwsise operations:
int nValue = 0;
int nTest = 0x00000001;
if(nValue & nTest) // Will be false
// Add nTest to nValue
nValue = nValue | nTest; // Can also do nValue |= nTest
if(nValue & nTest) // Will now be true
// Remove nTest from nValue
// Add nTest to nValue
nValue = nValue & ~nTest;
if(nValue & nTest) // Will now be false again
int nTest = 0x00000001;
if(nValue & nTest) // Will be false
// Add nTest to nValue
nValue = nValue | nTest; // Can also do nValue |= nTest
if(nValue & nTest) // Will now be true
// Remove nTest from nValue
// Add nTest to nValue
nValue = nValue & ~nTest;
if(nValue & nTest) // Will now be false again