functionlua

Lua only call a function if it exists?


I would like to call a function in a Lua file but only if the function exists, How would one go about doing this?


Solution

  • Try:

    if foo ~= nil then foo() end