[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Lua Tutor (Delphi + Lua)
- From: "Marius Gheorghe" <mgheorghe@...>
- Date: Wed, 28 Jun 2006 11:45:11 -0400
> What am I doing wrong?
> Thank you.
You forgot to add lua_call() or lua_pcall(). See below (untested!):
function call_add_xy(L: Plua_State; x, y: Double): Double;
begin
// Push functions and arguments:
lua_getglobal(L, 'add_xy'); // Function to be called.
lua_pushnumber(L ,x); // Push 1st argument.
lua_pushnumber(L, y); // push 2nd argument.
If lua_pcall(L, 2, 1, 0) = 0 then
Result := lua_tonumber(L, -1)
Else
Assert(false, 'Call failed!');
// pop returned value:
lua_pop(L, 1);
end;