raze/polymer/eduke32/source/lunatic/map2text.lua
helixhorned f133be4ae8 Add map2text.lua and helper script mapdiff.sh.
git-svn-id: https://svn.eduke32.com/eduke32@2964 1a8010ca-5511-0410-912e-c29ae57300e0
2012-08-26 22:09:34 +00:00

83 lines
2 KiB
Lua
Executable file

#!/usr/bin/env luajit
local B = require("build")
local string = require("string")
local fn = arg[1]
if (fn==nil) then
print("Usage: map2text <somefile.map>")
return 1
end
local function printf(fmt, ...)
print(string.format(fmt, ...))
end
local map, errmsg = B.loadboard(fn)
if (map == nil) then
printf("Couldn't load \"%s\": %s", fn, errmsg)
return 1
end
printf("numsectors = %d", map.numsectors)
printf("numwalls = %d", map.numwalls)
printf("numsprites = %d", map.numsprites)
printf("startpos = { %d, %d, %d }", map.start.x, map.start.y, map.start.z)
printf("startang = %d", map.start.ang)
printf("startsectnum = %d", map.start.sectnum)
local sector_members = {
"wallptr", "wallnum",
"ceilingz", "floorz",
"ceilingstat", "floorstat",
"ceilingpicnum", "ceilingheinum",
"ceilingshade",
"ceilingpal", "ceilingxpanning", "ceilingypanning",
"floorpicnum", "floorheinum",
"floorshade",
"floorpal", "floorxpanning", "floorypanning",
"visibility", "filler",
"lotag", "hitag", "extra",
}
local wall_members = {
"x", "y",
"point2", "nextwall", "nextsector",
"cstat",
"picnum", "overpicnum",
"shade",
"pal", "xrepeat", "yrepeat", "xpanning", "ypanning",
"lotag", "hitag", "extra",
}
local sprite_members = {
"x", "y", "z",
"cstat", "picnum",
"shade",
"pal", "clipdist", "filler",
"xrepeat", "yrepeat",
"xoffset", "yoffset",
"sectnum", "statnum",
"ang", "owner", "xvel", "yvel", "zvel",
"lotag", "hitag", "extra",
}
local function print_members(map, struct, members)
printf("%s = {", struct)
for i=0,map["num"..struct.."s"]-1 do
printf("[%d]={", i)
for j=1,#members do
local member = members[j]
printf("%s = %d", member, map[struct][i][member])
end
print("}")
end
print("}")
end
print_members(map, "sector", sector_members)
print_members(map, "wall", wall_members)
print_members(map, "sprite", sprite_members)