lua-users home
lua-l archive

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


I will consult the Lua documentation trying to know how to capture the erros. But bellow, I show you how I call Lua script. It's very simple code. Actually, I learnt recently after an answer given by one lister.

program test;

{$apptype gui}

{$mode objfpc}

uses

sysutils, lua;

var

l: plua_state;



function lua_random(l :plua_state):integer; cdecl;

var

n: integer;

begin

n := random(255);

lua_pushnumber(l, n);

result := 1;

end;

begin

randomize;

l := lua_open;

luaL_LoadFile(l, 'test.llua');

luaL_openlibs(l);

lua_register(l, 'random', @lua_random);

lua_pcall(l, 0, 0, 0);

lua_close(l);

end.




----- Original Message ----- From: "Wesley Smith" <wesley.hoke@gmail.com>
To: "Lua list" <lua@bazar2.conectiva.com.br>
Sent: Thursday, December 31, 2009 5:47 PM
Subject: Re: Adding new paths for the access of embedded programs


if you require a module and Lua can't find it then you definitely have
errors.  You just need to read up on the Lua documentation to figure
out how to get them.  How are you loading your Lua code?

wes