Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/ruby
- require 'pp'
- require 'csv'
- league = "Beyond"
- puts "BB begins here"
- puts "--------------"
- puts "IGN is Koverina, PM me in game if you want to make a purchase"
- # This creates an array of arrays - but we only need the first field
- data = CSV.read(ARGV[0]).map! {|line| line.first}
- # Only use buyout tabs - temporary workaround until Looty does specific tab export
- data = data.reject! {|line| line !~ /^~b\/o/}.compact
- # Parse for buyouts, line is a string like "~b/o 2 chaos x:1 y:2"
- prices = {}
- items = []
- data.each do |line|
- buyout = line.match(/^(.*)\s\bx:/)[1]
- x = line.match(/\bx:(\d*)\b/)[1]
- y = line.match(/\by:(\d*)\b/)[1]
- prices[buyout] = [] if prices[buyout].nil?
- # Looty indexs coords from 1, PoE indexes from 0
- prices[buyout] << { :x => x.to_i - 1, :y => y.to_i - 1 }
- end
- # Needed until Looty can give us the stash ID in the CSV
- stash_offset = 7
- stashes = prices.keys
- # Now re-loop to produce the bbcode
- prices.each do |price,items|
- puts ""
- puts "[spoiler=\"#{price}\"]"
- items.each do |item|
- location = "Stash#{stashes.index(price)+stash_offset}"
- coord = "x=\"#{item[:x]}\" y=\"#{item[:y]}\""
- print "[linkItem location=\"#{location}\" league=\"#{league}\" #{coord}]"
- end
- puts ""
- puts "[/spoiler]"
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement