title: Getting substrings in LuaU
body: <p>the title might look very stupid but I really can't find out what the problem is, I have created a custom function to substring like the way in C++ because I like it:</p>
  <pre class="lang-lua prettyprint-override"><code>local function SubStr(String, Start, Count)
      return String:sub(Start, Start+(Count-1))
  end
  </code></pre>
  <p>This is the code I am using, the substring function seems to work for the Bit Depth, Width and height, though when reading the colour values, it seems to offset a ton and I'm not sure what it is:</p>
  <pre class="lang-lua prettyprint-override"><code>        print(&quot;BitDepth&quot;, SubStr(Text, 1, 8))
          print(&quot;Width&quot;, SubStr(Text, 9, 8))
          print(&quot;Height&quot;, SubStr(Text, 17, 8))
          
          Image[&quot;BitDepth&quot;] = tonumber(SubStr(Text, 1, 8), 2)
          Image[&quot;Width&quot;] = tonumber(SubStr(Text, 9, 8), 2)
          Image[&quot;Height&quot;] = tonumber(SubStr(Text, 17, 8), 2)
  
          for i = 1, Image[&quot;BitDepth&quot;] do
              Image[&quot;Colours&quot;] = {};
              Image[&quot;Colours&quot;][i] = {};
              
              print(&quot;RED&quot;, SubStr(Text, (24*i), 8))
              print(&quot;BLUE&quot;, SubStr(Text, (24*i)+8, 8))
              print(&quot;GREEN&quot;, SubStr(Text, (24*i)+16, 8))
              print(&quot;ALPHA&quot;, SubStr(Text, (24*i)+24, 8))
  </code></pre>
  <p><a href="https://i.stack.imgur.com/V1EYx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/V1EYx.png" alt="" /></a></p>
  <p>The intended binary colour values for when <code>i</code> = <code>1</code>, should all be <code>11111111</code></p>
  <p>By the way this is reading the following binary string:</p>
  <p><code>000000110000100000001000111111111111111111111111000000000000000000000000111111110000000000000000000000000000000011111111</code></p>