Jump to content

» «

Python update = old scripts do not work anymore.

No replies to this topic
  • X-Seti

    .Retro mod developer. (Xenon Brothers)

  • Feroci
  • Joined: 28 Jun 2005
  • Canada
  • Contribution Award [Mods]


Posted 13 October 2012 - 04:28 PM

I have been using a lot of scripts to do the donkey work for GTASOL:

Mainly for ID, Co-ords, File name changes.

I wanted to update a lot of my old .IDE text files over to the newest version of the mod, but running them I find that because of the latest version of Python these scripts no longer work.

I need help..

My ID numeric order script is.


import sys, os

if len(sys.argv) < 4:
sys.exit('Usage: Source ide | ID number | Dest ide filename.')

def process_ide(ide_source, num, ide_destination):
src = open(ide_source,'r')
dst = open(ide_destination,'w')

for line in src:
 ide_line = line
 if not (line == "" or line[0]=="#" or len(line.split(",")) < 2):
  ide_line = line.split(",")
  ide_line[-1] = ide_line[-1][:-2]
  ide_line[0] = num
  ide_line = reduce(lambda x,y: str(x)+","+str(y), ide_line)+"\n"

process_ide(sys.argv[1], int(sys.argv[2]), sys.argv[3])

The syntax is ./solrem.py filenameIn.ide 1845 filenameOut.ide

This script was meant to renumber everything in an IDE files ID entry from 1845 upwards.

Issue 2:

The next script was designed to update every IPL file by what is stored in the IDE files where the IDE files might have been changed by the first script..


import sys, os

if len(sys.argv) < 4:
print "Usage: ",sys.argv[0],"<source ipl file> <destination file to write the ipl> one or more ide files here"

def read_gtaide(idef):
data = list()
f = open(idef,'r')
for line in f:
 if line == "" or line[0]=="#" or len(line.split(",")) < 2:
  ideline = line.split(",")
  ideline[-1] = ideline[-1][:-1]


return data

def search_by_model_name(model_name, ide_data):
l = filter(lambda x: model_name==x[1],ide_data)

return l
def process_ipl(ipl_data, ide_data):
new_ipl = list()

for line in ipl_data:
 ipl_line = line
 modelname = line[1]
 ide_line = search_by_model_name(modelname, ide_data)
 if len(ide_line) > 0: #if the resulting list has one or more matched lines
  ipl_line[0] = ide_line[0][0] #matched lines with given model name, ids on these are all the same, so pick the first
return new_ipl
def write_ipl_file(ipl_data, filename):
sep = os.linesep
f = open(filename,'w')


for line in ipl_data:
 f.write(reduce(lambda x,y: x+","+y, line)+os.linesep)


ipl_data = read_gtaide(sys.argv[1])
ide_data = list()

for ide in sys.argv[3:]:

processed_data = process_ipl(ipl_data, ide_data)

The now my next issue is to be able to rename everything in a unique way.

And this is where I have not written a script yet but waited until I sorted these 2 out first.

If there is someone out there who has a little spear time, drop me a line.

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users