Created
November 25, 2012 06:43
-
-
Save cmhobbs/4142659 to your computer and use it in GitHub Desktop.
Path Macro Maker for TinyFugue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
def path_maker(name, path) | |
input_array = path.split | |
defstring = "/def #{name} = " | |
path = [] | |
input_array.each do |step| | |
if step[0].match(/\d/) | |
s = split_step(step) | |
s[0].times { path << s[1] } | |
else | |
path << step | |
end | |
end | |
return defstring + path.join("%;") | |
end | |
def split_step(step) | |
return [step.match(/\d+/)[0..-1][0].to_i, step.split(/\d/)[-1]] | |
end | |
puts path_maker(ARGV[0], ARGV[1]) |
Just found a bug where the script doesn't account for path numbers larger than 9 (for example, 12w would mangle the path). Fix incoming.
Fixed to account for an arbitrary multiplier for a given step.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
PS - Join me at
faeroes.sdf.org
port 4000. You don't have to be a member of the SDF Public Access UNIX System to play, but we'd love to see you there, too!