Skip to content

Instantly share code, notes, and snippets.

@milkey-mouse
Last active January 22, 2018 00:28
Show Gist options
  • Save milkey-mouse/74a320017c67d417245f to your computer and use it in GitHub Desktop.
Save milkey-mouse/74a320017c67d417245f to your computer and use it in GitHub Desktop.
from xml.dom.minidom import parse, parseString
fp = r"C:\Program Files (x86)\Steam\SteamApps\common\Besiege\Besiege_Data\SavedMachines\binch.bsg"
dom = parse(fp)
nummemes = 0
for block in dom.getElementsByTagName("Block"):
if block.attributes["id"].value == "59":
data = block.getElementsByTagName("Data")[0].getElementsByTagName("Single")
for att in data:
if att.attributes["key"].value == "bmt-duration":
nummemes += 1
delay = 1
step = 0.01
for block in dom.getElementsByTagName("Block"):
if block.attributes["id"].value == "59":
data = block.getElementsByTagName("Data")[0].getElementsByTagName("Single")
for att in data:
if att.attributes["key"].value == "bmt-duration":
att.childNodes[0].nodeValue = str(delay)
delay += step
elif att.attributes["key"].value == "bmt-strength":
att.childNodes[0].nodeValue = "6"
elif att.attributes["key"].value == "bmt-charge":
att.childNodes[0].nodeValue = "0"
with open(fp, "w") as thing:
thing.write(dom.toxml())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment