lua-users home
lua-l archive

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


thanks steve it works, i never think about lua_isfunction(L, -1), its save my program from so many crashes.
From: steve donovan <steve.j.donovan@gmail.com>
Subject: Re: Function is available ?!
To: "Lua mailing list" <lua-l@lists.lua.org>
Date: Saturday, December 4, 2010, 10:52 AM

On Sat, Dec 4, 2010 at 6:42 PM, Peyman <peiman_3009@yahoo.com> wrote:
> this is possible to know a function in lua is exist before i want call it with lua_call ?

>From the manual:
"int lua_isfunction (lua_State *L, int index);

Returns 1 if the value at the given acceptable index is a function
(either C or Lua), and 0 otherwise."

So if you get your function somewhere (maybe look it up globally) then
lua_isfunction(L,-1) will tell you if the object on the top of the
stack is indeed a function.

steve d.