View Single Post
soccermitchy
New Member
Join Date: Feb 2014
Old 02-08-2014 , 21:57   Re: No #base or #include in config files?
Reply With Quote #4

So, I just wrote a preprocessor script that does this for me in Lua.
Code:
if not arg[1] then error "No template file given." end
print("Generating tf2items configuration from "..arg[1])
local finishedFile = ""
function parse(file)
  local out=""
  for line in io.lines(file) do
    if line:match("[ \t]+#inc \"(.+)\"") then
      print("included file: "..line:match("[ \t]+#inc \"(.+)\""))
      out=out..parse(line:match("[ \t]+#inc \"(.+)\""))
    else
      out=out..line.."\n"
    end
  end
  return out
end
finishedFile=parse(arg[1])
print("Done generating output.")
f=io.open("tf2items.weapons.txt","w")
f:write(finishedFile)
f:close()
Run it with lua script.lua template.txt
where a template is like a normal config file but lets you include files with #inc "filename"

Last edited by soccermitchy; 02-08-2014 at 21:58.
soccermitchy is offline