title: How to add to a Lua DissectorTable?
body: <p>I'm writing a Lua dissector for Wireshark for a complex protocol. The protocol has a message header that includes a msgType field. I want to write a subdissector for each message type, with each subdissector stored in a separate source file.</p>
  
  <p>My top-level script is general.lua which dissects the message header and creates the dissector table:</p>
  
  <pre><code>DissectorTable.new("myProtocol.Message")
  dofile(DATA_DIR.."cplane.lua")
  </code></pre>
  
  <p>cplane.lua is a subdissector for message type 'cplane' and includes the code:</p>
  
  <pre><code>my_dissector_table = DissectorTable.get("myProtocol.Message")
  my_dissector_table:add(0x02, myProtocol_cplane_proto)
  </code></pre>
  
  <p>Both scripts are in the same subdirectory of Wireshark's plugins directory.</p>
  
  <p>When I load the plugins I get error:</p>
  
  <pre><code>Lua: Error during loading:
   [string "C:\Program Files (x86)\Wireshark\plugins\2.4...."]:9: bad argument 
  #1 to 'get' (DissectorTable_get: no such dissector_table)
  
  Lua: Error during loading:
   [string "C:\Program Files (x86)\Wireshark\plugins\2.4...."]:170: bad 
  argument #1 to 'dofile' (dofile: file does not exist)
  </code></pre>
  
  <p>How can I fix this?  Is the problem to do with the loading order of the scripts?  Is the dofile() call necessary?</p>