mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-11 18:50:46 +00:00
build.lua: provide simplistic "readdefs()", use in foreachmap.lua.
So that symbolic tile names can be used when searching maps. git-svn-id: https://svn.eduke32.com/eduke32@3212 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
1009e0f2ec
commit
d5fa8ade49
2 changed files with 29 additions and 0 deletions
|
@ -13,6 +13,7 @@ local assert = assert
|
||||||
local print = print
|
local print = print
|
||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
local tostring = tostring
|
local tostring = tostring
|
||||||
|
local tonumber = tonumber
|
||||||
|
|
||||||
module(...)
|
module(...)
|
||||||
|
|
||||||
|
@ -377,3 +378,27 @@ function loadarts(filenames)
|
||||||
|
|
||||||
return tile
|
return tile
|
||||||
end
|
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
|
||||||
|
|
|
@ -18,6 +18,9 @@
|
||||||
-- and for each matching sprite also print its lotag and picnum:
|
-- and for each matching sprite also print its lotag and picnum:
|
||||||
-- ./findmaps.sh ~/.eduke32/ "sprite: .lotag < -1 :: io. write(', '.. .lotag .. ' ' .. .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 B = require "build"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
local io = require "io"
|
local io = require "io"
|
||||||
|
@ -75,6 +78,7 @@ if (modname:sub(1,2) == "-e") then
|
||||||
end
|
end
|
||||||
|
|
||||||
local successfunc, errmsg = loadstring(
|
local successfunc, errmsg = loadstring(
|
||||||
|
"local d=require('build').readdefs('../../names.h') or error('Need ../../names.h')\n".. -- XXX
|
||||||
"local numsectors, numwalls, numsprites\n"
|
"local numsectors, numwalls, numsprites\n"
|
||||||
.."local sector, wall, sprite\n"
|
.."local sector, wall, sprite\n"
|
||||||
.."return function (map, fn) \n"
|
.."return function (map, fn) \n"
|
||||||
|
|
Loading…
Reference in a new issue