<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Bitwise Operators for scripting]]></title><description><![CDATA[<p dir="auto"><strong>I just copy/pasted this from a text file… too lazy to format it</strong> :D</p>
<p dir="auto">With all integer value ifchecks, allow the following operators along with the relationals:</p>
<p dir="auto">| Bitwise ON (if tokenvalue $n 12345 0 | 4 -&gt; ANDs v0 with 4, and is true if non-zero)</p>
<p dir="auto">&amp; Bitwise OFF (opposite polarity to |)</p>
<p dir="auto">^ Bitwise Toggle (toggles the value then checks to see if it's non-zero)</p>
<p dir="auto">For the ON/OFF operators, if multiple bits are given (eg. value of 3), ANY of the bits can</p>
<p dir="auto">match the condition and be true. To check for ALL being ON or OFF, do each individually.</p>
<p dir="auto"></p><div class="plugin-markdown"><input type="checkbox" />notation as operators.</div><p></p>
<p dir="auto">When used in this fashion, they DO those operations.</p>
<p dir="auto">| would SET bits.</p>
<p dir="auto">&amp; would reset them.</p>
<p dir="auto">^ would do a toggle.</p>
<p dir="auto">Examples:</p>
<p dir="auto">token adjust $n 12345 0 &amp; 4</p>
<p dir="auto">token adjust $n 12345 0 | 2</p>
<p dir="auto">token adjust $n 12345 0 ^ 6 (toggles both bits 1 and 2)</p>
<p dir="auto">I could see these used as script flags. The only caveat is that the limit on bit position</p>
<p dir="auto">is like bit 29 to make sure all values stay within the upper limit of 2000000000.</p>
<p dir="auto">Knowing the binary values for each bit may be a bit much for some scriptors. Plus when</p>
<p dir="auto">looking at a combination, it can be difficult to perceive what they are. So here are some</p>
<p dir="auto">$[] functions for this:</p>
<p dir="auto">[hex &lt;hex digits=""&gt;] Range: 00000000 to 3FFFFFFF</p>
<p dir="auto">[bin &lt;binary digits=""&gt;] Range: 00000000000000000000000000000000 to 00111111111111111111111111111111</p>
<p dir="auto">[bit &lt;position&gt;] Range: 0 to 29</p>
<p dir="auto">[bits &lt;int list=""&gt;] Range: 0 to 29, in a space seperated list. ORs the bits together.</p>
<p dir="auto">Examples:</p>
<p dir="auto">token adjust $n 12345 0 = $[[bit 0]+[bit 10]] (sets it to 1+1024)</p>
<p dir="auto">token adjust $n 12345 0 = $[[bits 0 10]] (same as above, but shorter)</p>
<p dir="auto">token adjust $n 12345 0 = $[[hex 401]] (same as above, but using the hex form, not as explicit)</p>
<p dir="auto">if tokenvalue $n 12345 0 | $[[bit 0]] (checks for odd or just if that bit is on)</p>
<p dir="auto">if tokenvalue $n 12345 0 &amp; $[[bit 0]] (checks for even or just if that bit is off)&lt;/int&gt;&lt;/position&gt;&lt;/binary&gt;&lt;/hex&gt;</p>
]]></description><link>https://forum.v2.sentiencemud.net/topic/445/bitwise-operators-for-scripting</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Apr 2026 22:46:04 GMT</lastBuildDate><atom:link href="https://forum.v2.sentiencemud.net/topic/445.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 06 Sep 2006 02:17:24 GMT</pubDate><ttl>60</ttl></channel></rss>