diff --git a/polymer/eduke32/source/lunatic/build.lua b/polymer/eduke32/source/lunatic/build.lua index 04505d50e..f40dcd6dc 100644 --- a/polymer/eduke32/source/lunatic/build.lua +++ b/polymer/eduke32/source/lunatic/build.lua @@ -13,6 +13,7 @@ local assert = assert local print = print local setmetatable = setmetatable local tostring = tostring +local tonumber = tonumber module(...) @@ -377,3 +378,27 @@ function loadarts(filenames) return tile end + +function readdefs(fn) + local fh, errmsg = io.open(fn) + + if (fh==nil) then + return nil, errmsg + end + + local defs = {} + + while (true) do + local line = fh:read() + if (line == nil) then + break + end + local defname, numstr = string.match(line, "#?%s*define%s+([%a_][%w_]+)%s+([0-9]+)") + if (defname) then + defs[defname] = tonumber(numstr) + end + end + + fh:close() + return defs +end diff --git a/polymer/eduke32/source/lunatic/foreachmap.lua b/polymer/eduke32/source/lunatic/foreachmap.lua index 2f741e2e7..035c37040 100755 --- a/polymer/eduke32/source/lunatic/foreachmap.lua +++ b/polymer/eduke32/source/lunatic/foreachmap.lua @@ -18,6 +18,9 @@ -- and for each matching sprite also print its lotag and picnum: -- ./findmaps.sh ~/.eduke32/ "sprite: .lotag < -1 :: io. write(', '.. .lotag .. ' ' .. .picnum)" +-- The local 'd' provides defs loaded from ../../names.h, example: +-- ./findmaps.sh ~/.eduke32/ "sprite: .picnum>=d. CRACK1 and .picnum<=d. CRACK4" + local B = require "build" local string = require "string" local io = require "io" @@ -75,6 +78,7 @@ if (modname:sub(1,2) == "-e") then end local successfunc, errmsg = loadstring( + "local d=require('build').readdefs('../../names.h') or error('Need ../../names.h')\n".. -- XXX "local numsectors, numwalls, numsprites\n" .."local sector, wall, sprite\n" .."return function (map, fn) \n"