On 9/5/2021 12:01 PM, Henning Hraban Ramm via ntg-context wrote:
Hi again, I’m converting a few macros into Lua (LMTX), but couldn’t find some answers in the docs:
* How translates \ifodd\realpageno ?
This doesn’t work: if ((tex.getcount("realpageno") mod 2) == 1) then a = 1 end
we're talking lua: 9 % 2 == 0
TeX: \def\Something{1cm}
Lua: context.Something()
yes (assuming you're in scope) * TeX primitives
Is tex.strut and tex.par supposed to work? Or how should I access these?
\strut is not is primitive context.strut() and context.par() should just work
0) I don’t understand what “permanent” does and why I should maybe disable it. (cld-mkiv, p.146)
overload protection \permanent\def\Whatever{?} \overloadmode=0 %\overloadmode=3 %\overloadmode=4 \def\Whatever{!} try 3 and 4 (actually, try to run your documents with overloadmode set and you might see where you replace core macros) %enabledirectives[overloadmode=warning] \enabledirectives[overloadmode=error] btw, you can temporary do \pushoverloadmode potentially risky definitions \popoverloadmode
1) The parameter y is actually supposed to be a dimension, but if I declare it "dimen", ConTeXt says there wasn’t a number at "1cm". Or is a measure like that not a dimension?
if you want to use {} around it use "dimenargument"
2) The original interface of \MyFun had two optional parameters. I couldn’t find how to do that with interfaces.implement. cld-mkiv, p.151 (12.7) shows how to do lists or key=value, but not single optional args.
there is "optional" and ... cld is not yet updated to lmtx in this respect so some newer features are missing Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------