[NTG-context] Custom lua script (updating and debugging)

Hans Hagen pragma at wxs.nl
Wed Sep 29 09:23:16 CEST 2010


On 29-9-2010 8:50, Procházka Lukáš Ing. - Pontex s. r. o. wrote:
> Hello,
>
> I have also the experience that when the Lua file is placed where the
> LUA_PATH system variable points (or: see the documentation how exactly
> LUA_PATH works), than I can use the 'require' command and the Lua file
> will be found.
>
> E.g.:
>
> LUA_PATH = (...);C:\MyDir\?.lua
>
> C:\MyDir\MyFile.lua:
>
> print("This is MyFile.lua")
>
> And a ctx file:
>
> \startluacode
> require("MyFile")
> \stopluacode
>
> - Will print "This is MyFile.lua" to the output stream when converting
> .tex to (e.g.) .pdf.

texmf-[local|project]/scripts/context/lua

should work out ok with require, given that you also have regenerated 
the file database

> Lukas
>
>
> On Tue, 28 Sep 2010 21:30:32 +0200, Mojca Miklavec
> <mojca.miklavec.lists at gmail.com> wrote:
>
>> On Tue, Sep 28, 2010 at 12:41, Stefan Müller wrote:
>>> Hi list,
>>>
>>> I'm currently messing around with a custom lua script (a pretty
>>> printer) and
>>> I have some beginner trouble.
>>>
>>> First: I put the file in "MyContexDir\tex\texmf\tex\context\base\".
>>
>> Put them into
>> MyContexDir\tex\texmf-local\tex\context\user\
>> because:
>> - You need to use texmf-local instead of texmf, else your file might
>> be deleted when you update the distribution.
>> - It doesn't really matter where the file is as long as it is under
>> [TEXMF]\tex\context, but using "user" is somehow more sensible than
>> "base".
>>
>>> What do
>>> I have to do to let ConTeXt work with the script and to let ConTeXt know
>>> that something has changed in the script? Is "context --generate" enough
>>> (after initializing with "setuptex.bat")?
>>
>> You need to use context --generate only when you add the script for
>> the first time. After you modify it, you don't need to do anything
>> unless you are changing ConTeXt source. If you change ConTeXt source,
>> you need to also run "context --make" (but that would be dangerous
>> anyway).
>>
>>> Second: How can I debug errors in my *.lua file? Just put
>>> print("debug message")
>>> in the function that is (supposed to be) called?
>>
>> Yes, or tex.print (depending on how you want to debug).
>>
>> Mojca
>> ___________________________________________________________________________________
>>
>> If your question is of interest to others as well, please add an entry
>> to the Wiki!
>>
>> maillist : ntg-context at ntg.nl /
>> http://www.ntg.nl/mailman/listinfo/ntg-context
>> webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
>> archive : http://foundry.supelec.fr/projects/contextrev/
>> wiki : http://contextgarden.net
>> ___________________________________________________________________________________
>>
>>
>
>


-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------


More information about the ntg-context mailing list