Grognak wrote:tdoe wrote:Hey again, How do I put .zip files into the Mod Manager? Some of the mods I downloaded are in .zip form and im not sure how to convert them to .ftl files
If it's .zip, it probably isn't compatible with GMM! Ask the author to convert it (if not for convenience reasons, for ethical ones.)
I thought you added zip support in 1.3?
On a semi-related note, have you gotten anywhere with adding XML merging?
I was able to get Nokogiri in Ruby to finally actually
parse the base XML files with a number of workarounds:
For each line of the source files and mod files which contain anything other than tabs/spaces/newlines, I performed the following steps (presented with regex to be language agnostic):
- Remove any/all beginning/trailing spaces (unnecessary, adds extra whitespace nodes which may slow performance; not completely necessary)
- Replace anything matching /\s=\"/ with '="'
- Replace anything matching /\=\s\"/ with '="' (these two remove spaces around the '=' in property assignments, which is nonstandard XML)
- Replace anything matching /(\S+?)-->/ with '\1 -->' (\1 = first matching group; many XML parsers are unable to handle comment nodes with either more -'s than two before the closing comment tag, so we're adding an extra space to the end so it matches)
- Replace anything matching /<!--(\S+?)/ with '<!-- \1' (same as above, but for the beginning of the comment node)
- Replace anything matching /(\s\w+=\"\S+?\")(\S+>)/ with '\1 \2' (Several locations have XML nodes like <tagName attribute="value"attribute2="value" />; A majority of XML parsers blow up on this, so this spaces all attributes out)
In Ruby, this was implemented as follows:
Code: Select all
def contents (filename)
f = File.open(filename)
t = f.read
f.close
return t.each_line.map{|x| x.strip.gsub(/\s=\"/, '="').gsub(/\=\s\"/, '="').gsub(/(\S+?)-->/, '\1 -->').gsub(/<!--(\S+?)/, '<!-- \1').gsub(/(\s\w+=\"\S+?\")(\S+>)/, '\1 \2') unless x.strip.empty?}.compact * ""
end
Presumably, something similar can be incorporated within Python, though you still have design considerations to determine how best to actually handle the merging itself (ie adding attributes to mods - my current method was to look for a "mergeMode" attribute in the mod file which either indicated that its children should be merged by tagName/name, or that its children should replace any matching tagName/name, etc).
There doesn't seem to be a "right" or "wrong" way to do that. I may look into seeing what "packaging" options are available for installing Rubygems to possibly provide my almost-but-not-quite working Ruby version, but since redistribution requires it to be run locally, I'd either need to provide a Ruby/Gem bundled installer, or have end users install both Ruby and a Gem to use it, which seems quite untenable, lol.
[edit]
One other thing - in Ruby/Nokogiri (which uses libxml2, which I think it what the native Python XML parsers also use), I had to specify the input as an XML fragment, since the XML standard only allows for a single root node. If the parser you end up using doesn't have this as an option, you'll need to find some manner to work around this, though with the base game files, you'd need to do more than simply wrap the entire file in <ftlRoot></ftlRoot> tags, since that would wrap the XML directive at the top inside, and that would need to come before the root note (that's the <?xml version="1.0" encoding="utf-8"?> part).