Re: [NTG-context] passing variables/data between context and lua

2019-10-08 Thread Rudolf Bahr
On Tue, Oct 08, 2019 at 08:55:30AM -0400, Aditya Mahajan wrote: > So, everytime \setvariables is call, the value of the `set` key is executed. Hello Aditya, this is the key sentence to understand better what "reset" and "set" are good for! I had to read your explanation thrice :-) and run yo

Re: [NTG-context] passing variables/data between context and lua

2019-10-08 Thread Aditya Mahajan
On Tue, 8 Oct 2019, Rudolf Bahr wrote: On Sun, Oct 06, 2019 at 10:44:12PM +0200, Wolfgang Schuster wrote: While it is true that you're free to choose the name for the keys there are two keys with a special meaning, these two keys are "reset" and "set". The value of the "reset" key is used befo

Re: [NTG-context] passing variables/data between context and lua

2019-10-08 Thread Rudolf Bahr
On Sun, Oct 06, 2019 at 10:44:12PM +0200, Wolfgang Schuster wrote: > While it is true that you're free to choose the name for the keys there are > two keys with a special meaning, these two keys are "reset" and "set". The > value of the "reset" key is used before the values in \setvariables are >

Re: [NTG-context] passing variables/data between context and lua

2019-10-06 Thread Wolfgang Schuster
Rudolf Bahr schrieb am 06.10.2019 um 07:11: Hello Wolfgang, what exactly does the command "\setvariable{martin}{set}{\directsetup{martin}}"? Let's start with a simple example where I set a values with the \setvariables command. \setvariables   [metadata]   [author=Rudolf Bahr,    date=\current

Re: [NTG-context] passing variables/data between context and lua

2019-10-05 Thread Rudolf Bahr
> A solution which uses only existing commands in the document. > > \startsetups [martin] > \startlua > local points = tonumber(\getvariable{martin}{question}) or 0 ; > points = points * 92 ; > local answer = 42 ; > context.setvariable("martin","points",po

Re: [NTG-context] passing variables/data between context and lua

2019-09-29 Thread Martin Althoff
Thanks for the quick answers. Both suggestions work for me. @Massi Thanks for the pointer into the cld-mkiv.pdf @Wolfgang: I have to admit that I don't completely comprehend your solution, though it works. Searching around for the commands you use, I came across an older posting you answered

Re: [NTG-context] passing variables/data between context and lua

2019-09-27 Thread Wolfgang Schuster
Martin Althoff schrieb am 27.09.2019 um 06:59: Hi, I am trying to pass variables/data between context and lua. Lua would be used for calculations on data coming from context. Unfortunately I can't figure out what to do. The code below doesn't work, but is there to illustrate my idea. Any help

Re: [NTG-context] passing variables/data between context and lua

2019-09-27 Thread mf
\starttext \define\question{44} \startluacode -- see "ConTeXt Lua Documents" manual, §7.4 Looking inside local question = tokens.getters.macro("question") -- it's up to you to verify that \question contains a number -- better using the userdata table for your data userdata.points = tonumber( que

[NTG-context] passing variables/data between context and lua

2019-09-26 Thread Martin Althoff
Hi, I am trying to pass variables/data between context and lua. Lua would be used for calculations on data coming from context. Unfortunately I can't figure out what to do. The code below doesn't work, but is there to illustrate my idea. Any help would be much appreciated. Thanks, Martin \d