BitReplace

From Multi Theft Auto: Wiki
Revision as of 22:20, 2 October 2013 by ZoLo (talk | contribs) (Created page with "{{Server client function}} {{Needs_Example}} __NOTOC__ {{New feature/item|3.0132|1.3.2|5340| ... }} ==Syntax== <syntaxhighlight lang="lua"> uint bitReplace ( uint var, uint replaceValue, int f...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Accessories-text-editor.png Script Example Missing Function BitReplace needs a script example, help out by writing one.

Before submitting check out Editing Guidelines Script Examples.


...

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