lua-users home
lua-l archive

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


Hello Lua list,

Here's my second "always wanted to do" question:

I work on platforms (games consoles) where 'fopen' and friends don't
really have any meaning and are never called.  Other than that, the
platforms behave in a reasonably normal fashion.

My C application loads (using nonstandard proprietary functions) all the
scripts it is going to need as soon as it starts, and stores them as
"const char *" values in a big lookup table.  The table is indexed by
filename.  When the time comes to actually execute one of them, it is
passed to the lua_State using luaL_dostring.  So far, so good.

But I cannot figure out how to set up callbacks so that either "require"
or "dofile" work.

The perfect situation for me would be to supply the lua_State with a C
function that takes a filename and returns the loaded data.

Whenever I've had this problem in the past, I've usually registered my
own function that does essentially that, and told people writing scripts
to use that function instead of "require".  Or sometimes I just make a
rule of always running a certain file before any others.

Is there a better way of doing this?  I realise I could change lua's
source code, but I'd rather play within the existing rules.

Thanks again for the help,  (I see my previous question already has four
answers!)

Peter Pimley





.

__________________________________________________________________________________________________________________________________________
Information contained in this e-mail is intended for the use of the addressee only, and is confidential and may be the subject of Legal Professional Privilege.  Any dissemination, distribution, copying or use of this communication without prior permission of the addressee is strictly prohibited.The views of the author may not necessarily constitute the views of Kuju Entertainment Ltd. Nothing in this email shall bind Kuju Entertainment Ltd in any contract or obligation.

The contents of an attachment to this e-mail may contain software viruses which could damage your own computer system. While Kuju Entertainment has taken every reasonable precaution to minimise this risk, we cannot accept liability for any damage which you sustain as a result of software viruses. You should carry out your own virus checks before opening the attachment.

Kuju Entertainment Ltd trading as Zoe Mode

Registered Office : 185 Park Street, Bankside, London, SE19DY. Company Number : 3481384.Company Registered in England.
__________________________________________________________________________________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
_________________________________________________________________________________________________________________________________________