# [NTG-context] Problem calling Lua during \startsetups

Procházka Lukáš Ing. - Pontex s. r. o. LPr at pontex.cz
Tue Jan 25 09:00:58 CET 2011

Thank you, Wolfgang, this works better.

Actually I need to use '%' in the condition and that fails:

---
...
\startrawsetups layer
% The value of 'n' is used here to set the appropriate background,
% = n-th page of a PDF, and also to draw a filled rectangle on
% the left or right side (depending on whether n is even or odd)

% The code bellow fails

\startluacode
print("N=", n)

if n % 2 == 1 then

else

end
\stopluacode
\stoprawsetups
...
---

with:

---
! LuaTeX error <main ctx instance>:1: 'then' expected near 'else'.
---

So like '%' was still treated as TeX comment char.

How to enable '%'?

Best regards,

Lukas

NB: Dirty trick: to define a Lua function like 'function isEven(n) return n % 2 == 0 end' and to use this function at the place of 'n % 2 == 1'; but I'd rather avoid this.

--
Ing. Lukáš Procházka [mailto:LPr at pontex.cz]
Pontex s. r. o.      [mailto:pontex at pontex.cz] [http://www.pontex.cz]
Bezová 1658
147 14 Praha 4

Tel: +420 244 062 238
Fax: +420 244 461 038