[NTG-context] search path for require(...)

Ulrike Fischer news3 at nililand.de
Thu Mar 24 11:34:21 CET 2011


Am Thu, 24 Mar 2011 11:14:00 +0100 schrieb Philipp Gesang:

>> I'm trying to store the virtual lua chess fonts I'm currently
>> creating so that latex and context can use them. 
>> 
>> 1. At first I stored the vf-chess-XX.lua in tex/luatex. This works
>> for latex but not for context. tex/generic works for both. 
>> 
>> 2. My fonts loads a lua-file which should be shared by all fonts
>> with 
>> 
>> chessfss=require('chessfss')
>> 
>> latex finds the chessfss.lua without problems in various locations
>> (e.g. tex/generic) but context not. How can I solve this problem?
> 
> Hi Ulrike,
> 
> see also:
>   http://www.ntg.nl/pipermail/ntg-context/2010/047721.html

Ah. chessfss = require('chessfss.lua') works in context. And it
seems to work with latex too (I had somewhere in the back of my mind
the thought that the ".lua" extension breaks with latex but can't
reproduce it currently). 


> (You’re going to have to declare the table “chessfss” globally
> for this to work.)

The chessfss.lua has a "return Table" at the end which declares the
table chessfss. 

To quote from http://lua-users.org/wiki/LuaModuleFunctionCritiqued:

"The problems above can be avoided by not using the module function
but instead defining modules in the following simple way: [*1][*2] 

-- hello/world.lua
local M = {}

local function test(n) print(n) end
function M.test1() test(123) end
function M.test2() M.test1(); M.test1() end

return M

and importing modules this way: 

local MT = require "hello.world"
MT.test2()"


-- 
Ulrike Fischer 



More information about the ntg-context mailing list