Hello,
First the warning, for Hans in particular: make sure you start using require() for all of the external lua modules that are embedded in luatex. As soon as this new subsystem is in place, you can no longer use functions like socket.bind() without require-ing the module first!
ok, no problem for the scripts, but i have to figure out a way to embed them in the format
I use a custom package loader and bytecode registers. A toks register is used to map Lua module names to the number of the bytecode register the module is stored in. When require()ing a module, this toks register is checked: - Module exists: The bytecode register is executed. - Modules does not exist: A new bytecode register is reserved, the module loaded using loadfile(), executed and stored in the bytecode register. Finally, the mapping is added to the toks register. That does it. I also have a macro to do <global module var> = require("<module name>") and add code to \everyjob to do this again at the start of the TeX run if called in IniTeX. Maybe this helps, Jonathan P.S: My loader is (there is a toks register \LT:T@bytecode@files which stores the mapping from module name to bytecode register, and a count register \LT:C@next@bytecode which stores the number of the next unused bytecode register; ":" and "@" are letters): local escapeChars = { ['^'] = '%^', ['$'] = '%$', ['('] = '%(', [')'] = '%)', ['%'] = '%%', ['.'] = '%.', ['['] = '%[', [']'] = '%]', ['*'] = '%*', ['+'] = '%+', ['-'] = '%-', ['?'] = '%?' } local function loadfile(file, name) local f, e = io.open(file) if not f then return f, e end local s = f:read('*a') f:close() return loadstring(s, '@' .. name) end local function loader(moduleName) local fn = moduleName .. '.klua' local t = tex.toks['LT:T@bytecode@files'] local f, n = t:match('|(' .. fn:gsub('.', escapeChars) .. ')|=|([0-9]+)|') if f then texio.write_nl('') texio.write('(', fn, ' [from register ', n, '])') return lua.bytecode[n] else rn = kpse.find_file(fn, 'tex', true) if rn then f, e = loadfile(rn, moduleName) if f then if tex.formatname == '' then local r = tex.count['LT:C@next@bytecode'] tex.count['LT:C@next@bytecode'] = r + 1 texio.write_nl('') texio.write('(', rn, ' [cached in register ', r, '])') lua.bytecode[r] = f tex.toks['LT:T@bytecode@files'] = t .. '|' .. fn .. '|=|' .. r .. '|' else texio.write_nl('') texio.write('(', rn, ')') end return f else return 'Loader error: ' .. e end else return 'Loader error: Could not find file' end end end package.loaders = { loader }