Raised This Month: $51 Target: $400
 12% 

No #base or #include in config files?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
soccermitchy
New Member
Join Date: Feb 2014
Old 02-08-2014 , 16:11   No #base or #include in config files?
Reply With Quote #1

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)
soccermitchy is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 02-08-2014 , 20:49   Re: No #base or #include in config files?
Reply With Quote #2

tf2items_manager doesn't have any say in the file parsing, it's a standard Valve KeyValues file.
__________________
asherkin is offline
soccermitchy
New Member
Join Date: Feb 2014
Old 02-08-2014 , 21:41   Re: No #base or #include in config files?
Reply With Quote #3

Quote:
Originally Posted by asherkin View Post
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 is offline
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
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:18.


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