lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 06/10/2014 14.15, Charles Smith wrote:
Okay, I got it to work:

v = "m1"

function m1 ()
     print ("hello world")
end

_G[v]()

If I understand correctly what you would like to achieve:

------------------
  function Init()
      v = m1
  end

  function m1()
      print ("hello world")
  end

  Init()
------------------

This way, m1 is already defined when its value is used, because Init() is called after all chunk-level (global) assignments, such as "function m1" have been executed.

--
  Enrico