lua-users home
lua-l archive

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


 
In Lua code (Lua 4.0), I've tried to do the following:
 
  function ent_wall()
     -- do stuff...
  end
 
  function entity_spawn(name)
     args = {}
     call( "ent_" .. name, args) -- ERROR
  end
 
  entity_spawn("wall")
 
 
result is:
"Error: attempt to call a string value."
 
 
Of course, what this should have accomplished is:
 
  call(ent_wall, args)
 
So, how do I get a "handle" to function "funcname", having
it's (string) name? Like:
 
   handle = get funcion by name ("ent_wall")
 
   call(handle, args)  -- call global function "ent_wall"
 
(If there is no way other than implementing this in C yourself, this
would be a nice addition to Lua's baselib)
 
- Fabio