title: LuaJ :: Set variable in LuaFunction without using globals
body: <p>I have a LuaFunction where in I will call the invoke() method and pass in some var-args. I wish to pass some data to this LuaFunction such that it can be referenced by the lua code as if it was a built-in variable.</p>
  <p>For example, I want to have a variable named &quot;script&quot;. When a script class executes its lua code, and it references the &quot;script&quot; value, I want it to represent that script object, but only for that lua code--I want no other lua code to be able to see this variable.</p>
  <p>Currently, I am using Globals via:</p>
  <pre><code>globals.set(&quot;script&quot;, reference);
  function.invoke(args);
  </code></pre>
  <p>Lua code:</p>
  <pre><code>print(script)
  &gt; &quot;Script&quot;
  </code></pre>
  <p>While this does work, I can reference &quot;script&quot; in my lua code, this also sets _G.script, which I do not like.</p>
  <p>Does anyone have any ideas for this situation?</p>