AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   TF2Items (https://forums.alliedmods.net/forumdisplay.php?f=146)
-   -   No #base or #include in config files? (https://forums.alliedmods.net/showthread.php?t=235106)

soccermitchy 02-08-2014 16:11

No #base or #include in config files?
 
On the config files for TF2Items, it seems like you can't use #base or #include to include other files. This would be useful because you can then organize the custom weapon properties on a per-class basis (ie. have a separate file for every class)

asherkin 02-08-2014 20:49

Re: No #base or #include in config files?
 
tf2items_manager doesn't have any say in the file parsing, it's a standard Valve KeyValues file.

soccermitchy 02-08-2014 21:41

Re: No #base or #include in config files?
 
Quote:

Originally Posted by asherkin (Post 2097643)
tf2items_manager doesn't have any say in the file parsing, it's a standard Valve KeyValues file.

On the Valve developer wiki or w/e, it says that it has those features...

soccermitchy 02-08-2014 21:57

Re: No #base or #include in config files?
 
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"


All times are GMT -4. The time now is 15:38.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.