Hello, given is the following PlainTeX file: %&luatex % \message{\the\currentgrouplevel} \directlua0{texio.write_nl(tex.currentgrouplevel)} \bye This results in: This is LuaTeX, Version snapshot-0.29.0-2008072919 (Web2C 7.5.7) (currentgrouplevel.tex ! You can't use `\currentgrouplevel' as tex library index. l.3 ...lua0{texio.write_nl(tex.currentgrouplevel)} ? Looking into section 4.1.1 of the manual, currentgrouplevel is not in the list of tex's integer parameters -- unfortunately. It would be a quite useful addition in order to create `grouped variables' in Lua (variables whose previous value is restored at the end of a TeX group): -- Assume there are TeX two count registers allocated, `stackIndex' -- and `groupIndex' tex.count.stackIndex = 0 tex.count.groupLevel = -1 -- The `grouped variable' stack local stack = { } -- Sets a `grouped variable' function set(name, value) if tex.currentgrouplevel > tex.count.grouplevel then -- New group opened since the last time. Create a new stack -- element tex.count.stackIndex = tex.count.stackIndex + 1 stack[tex.count.stackIndex] = { } tex.count.groupLevel = tex.currentgrouplevel -- TODO: Optional: Clear the stack above the new element to -- release old values end -- Add the value stack[tex.count.stackIndex][name] = value end -- Gets a `grouped variable' function get(name) -- Look through the stack, top to bottom for i = tex.count.stackIndex, 1, -1 do if stack[i][name] then return stack[i][name] end end -- Value not found return nil end Jonathan