mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 03:00:46 +00:00
foreachmap.lua: add option of only printing matching file names (like grep -l)
Also, add convenience wrapper script findmaps.sh for quickly searching for sprites/walls/sectors satisfying a certain condition in all map files under a given directory. git-svn-id: https://svn.eduke32.com/eduke32@3030 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
599a2049e6
commit
99f9cfca7f
2 changed files with 25 additions and 5 deletions
16
polymer/eduke32/source/lunatic/findmaps.sh
Executable file
16
polymer/eduke32/source/lunatic/findmaps.sh
Executable file
|
@ -0,0 +1,16 @@
|
|||
#!/bin/sh
|
||||
|
||||
ok=yes
|
||||
if [ -z "$1" ]; then
|
||||
ok=
|
||||
fi
|
||||
if [ -z "$2" ]; then
|
||||
ok=
|
||||
fi
|
||||
|
||||
if [ -z "$ok" ]; then
|
||||
echo "Usage: $0 <dir> <code for foreachmap.lua -e>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
find -L "$1" -name '*.map' -print0 | xargs -0 ./foreachmap.lua "-e$2"
|
|
@ -31,7 +31,8 @@ if (#arg < 1) then
|
|||
wr("The third form is a shortcut for quickly finding sectors/walls/sprites\n")
|
||||
wr("satisfying a certain condition (see example below)\n\n")
|
||||
wr("Examples: ./foreachmap.lua -e\"if map.numbunches==1 then print(fn) end\" ~/.eduke32/*.map\n")
|
||||
wr(" ./foreachmap.lua -e\"sprite: .picnum==10 and .lotag==2563\" *.map\n\n")
|
||||
wr(" ./foreachmap.lua -e\"sprite: .picnum==10 and .lotag==2563\" *.map\n")
|
||||
wr(" ./foreachmap.lua -e\"sprite:: ... -- (only prints the file names)\n\n")
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -42,14 +43,17 @@ if (modname:sub(1,2) == "-e") then
|
|||
local body = modname:sub(3)
|
||||
|
||||
-- sector/wall/sprite finder shortcut
|
||||
local b, e, what = body:find("^([a-z]+):")
|
||||
local b, e, what = body:find("^([a-z]+)::?")
|
||||
if (what) then
|
||||
local onlyfiles = (body:sub(e-1,e)=="::") -- "::" means "only list files" (like grep -l)
|
||||
body = body:sub(e+1)
|
||||
body = body:gsub("%.[a-z]+", what.."[i]%0")
|
||||
body =
|
||||
"for i=0,num"..what.."s-1 do"..
|
||||
" if ("..body..") then print(fn..': '..i) end "..
|
||||
"end"
|
||||
"for i=0,num"..what.."s-1 do\n"..
|
||||
" if ("..body..") then\n"..
|
||||
(onlyfiles and "print(fn); return\n" or "print(fn..': '..i)\n") ..
|
||||
" end\n"..
|
||||
"end\n"
|
||||
end
|
||||
|
||||
local successfunc, errmsg = loadstring(
|
||||
|
|
Loading…
Reference in a new issue