Advertisement
Guest User

Change xcom variables

a guest
Mar 3rd, 2015
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.02 KB | None | 0 0
  1. import re
  2.  
  3. file = open("DefaultGameCore.ini", "r")
  4. file2 = open("DefaultGameCore2.ini", "w")
  5.  
  6. #   file is the file read from
  7. #   file2 is the file written to. Can change their names above.
  8.  
  9. for line in file:
  10.  
  11.     stringFound = re.search('iEnvironmentDamage=\d+', line)
  12.    
  13.     #change this line above to change what string is being searched.
  14.     #\d+ means one or more decimals. Be careful not to change all iHP in DGC.ini
  15.     #since it's too commonly used.
  16.     #One way to do it is just to cut and paste out an entire section of a
  17.     #variable you want to change and then apply this script.
  18.    
  19.     if stringFound:
  20.         myStringOri = stringFound.group(0);
  21.         envDmgNum = re.sub('iEnvironmentDamage=', '', myStringOri)
  22.         envDmgNum = str(int(envDmgNum) * 2)
  23.        
  24.         #change the *2 above to change how much env damage is increased/decreased.
  25.        
  26.         myStringNew = re.sub('\d+',envDmgNum,myStringOri)
  27.         line = re.sub('iEnvironmentDamage=\d+', myStringNew, line)
  28.         print (myStringOri)
  29.         file2.write(line)
  30.     else:
  31.         file2.write(line)
  32.        
  33. file.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement