BitReplace

From Multi Theft Auto: Wiki
Revision as of 12:31, 2 January 2014 by Myonlake (talk | contribs)
Jump to navigation Jump to search

This function returns the unsigned number formed by var value with replacement specified at bits field to field + width - 1

Syntax

uint bitReplace ( uint var, uint replaceValue, int field, int width = 1 )

Required arguments

  • var: The value
  • replaceValue: The replaceValue
  • field: The field number
  • width: Number of bits to extract

Returns

Returns the replaced value/bit sequence.

Example

function replaceColorAlpha(color, alpha)
   return bitReplace(color,alpha,24,8) -- return value with replaced bits 24-32 ( the alpha, http://en.wikipedia.org/wiki/RGBA_color_space ) 
end

See Also