title: lua - How do I access a variable in a elseif statement
body: <pre><code>--If STATEMENT
          elseif line:match("^if") then
              local v, e, c, v2 = line:match("^if (.+) = (.+) &gt; (.+) &gt; (.+)")
                  if vars[v] == e then
                      if c == "print" then
                          print(v2)
                      elseif c == "run" then
                          if funcs[v2] then
                              if funcs[v2] == "print" then
                                  print("hi")
                              end
                          end
                      end
                  end
  
          --Functions
          elseif line:match("^func") then
              local n, c, o = line:match("^func (.+) &gt; (.+) &gt; (.+)")
              funcs[n] = c
          end
  </code></pre>
  
  <p>This code is used for a programming language im developing and im having troubles with running functions</p>
  
  <p>While that code up there works, there is one problem...
  I want to print off the var "o" set in the elseif statement under "--Functions", it is detecting that i want to print something in the function but i just dont know how to access the variable o in a different elseif statement, because in the "--If statement" area it is looking to see if the code in the file looks similar to this <code>if var = 1 &gt; run &gt; functionname</code>  and the code in the file for a function looks like this <code>func functionname &gt; print &gt; Hello</code> which works and for dev purposes I made it print off "hi" so it is detecting in the function that i want to print but, in the section ("--function") i have a variable called o, which is what is supposed to be printed off, I hope i explaned well and I hope you guys understand, and thanks in advance</p>