Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re, os
- def populateResults(regex, line, results):
- result = regex.findall(line)
- if len(result) > 0:
- for element in result:
- return results.append(element)
- def printResults(results, itemName, noItemMessage):
- if len(results) > 0:
- for element in results:
- location = locationRegex.search(element)
- exits = exitsRegex.search(element)
- if location:
- resultString = itemName + ": X: " + location.group(1) + ", Y: " + location.group(2)
- if exits:
- resultString += ", TO: " + exits.group(1)
- print resultString
- else:
- print noItemMessage
- hldPath = "/Users/me/Library/Application Support/Steam/steamapps/common/HyperLightDrifter/HyperLightDrifter.app/Contents/Resources/"
- drifterBonesRegex = re.compile("obj,DrifterBones_Outfit.*")
- gearbitCrateRegex = re.compile("obj,Spawner.*GearbitCrate.*")
- doorRegex = re.compile("obj,door.*")
- teleporterRegex = re.compile("obj,Teleporter.*")
- elevatorRegex = re.compile("obj,Televator.*")
- locationRegex = re.compile("\w*,\w*,\d*,(?P<x>-?\d+),(?P<y>-?\d+),.*")
- exitsRegex = re.compile(".*r[m?]=(.*),dr=.*")
- for dirs, subdirs, files in os.walk(hldPath):
- for name in files:
- relDir = os.path.relpath(dirs, hldPath)
- relFile = os.path.join(relDir, name)
- if name.endswith(".lvl"):
- lvlFile = open(os.path.join(dirs, name), "r")
- print "===================="
- print relFile
- print "===================="
- drifterBonesResults = []
- gearbitCrateResults = []
- doorResults = []
- teleporterResults = []
- elevatorResults = []
- for line in lvlFile:
- populateResults(drifterBonesRegex, line, drifterBonesResults)
- populateResults(gearbitCrateRegex, line, gearbitCrateResults)
- populateResults(doorRegex, line, doorResults)
- populateResults(teleporterRegex, line, teleporterResults)
- populateResults(elevatorRegex, line, elevatorResults)
- print "Items"
- print "--------------------"
- printResults(drifterBonesResults, "DRIFTER BONES", "NO DRIFTER BONES")
- printResults(gearbitCrateResults, "GEARBIT CRATE", "NO GEARBIT CRATES")
- print
- print "Exits"
- print "--------------------"
- printResults(doorResults, "DOOR", "NO DOORS")
- printResults(teleporterResults, "TELEPORTER", "NO TELEPORTERS")
- printResults(elevatorResults, "ELEVATOR", "NO ELEVATORS")
- print
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement