Duvidas tem algum programa que converte os CreateDynamicObject antigos do Icognito para a nova versгo?
O meu estб assim CreateDynamicObject(ID, x, y, z, rx, ry, rz); O novo estб assim CreateDynamicObject(modelid, Float, Float:y, Float:z, Float:rx, Float:ry, Float:rz, worldid = -1, interiorid = -1, playerid = -1, Floattreamdistance = STREAMER_OBJECT_SD, Float:drawdistance = STREAMER_OBJECT_DD); |
# -*- encoding: UTF-8 -*-
'''
CreateDynamicObject(ID, x, y, z, rx, ry, rz);
CreateDynamicObject(modelid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz
, worldid = -1, interiorid = -1, playerid = -1, Float:streamdistance = STREAMER_OBJECT_SD, Float:drawdistance = STREAMER_OBJECT_DD);
'''
class IncognitoConverter:
method_name = None
def __init__(self, pattern):
self.pattern = pattern
self.result = []
def set_pattern(self, pattern):
self.pattern = pattern
def cast_process(self, old):
self.file = old.file
self.old_pattern = old.pattern
self.execute()
def execute(self):
with open(self.file, "r") as infile:
for line in infile:
self.extract_tokens(line)
self.catch_new_tokens()
self.process_message()
self.save_file()
def extract_tokens(self, line):
'''tmp = self.old_pattern
arr_tokens = tmp[tmp.find('(') + 1 : tmp.find(')')].split(',')
self.tokens = arr_tokens'''
tmp = line
arr_tokens = tmp[tmp.find('(') + 1 : tmp.find(')')].split(',')
self.tokens = arr_tokens
def save_file(self):
with open('casted_objects.txt', 'wb') as f:
for line in self.result:
f.write(line)
def process_message(self):
if not self.method_name:
self.method_name = self.pattern[0 : self.pattern.find('(')]
message = '{}('.format(self.method_name)
for i in self.tokens:
message = '{}{},'.format(message, i)
message = '{}'.format(message[0:-1])
message = '{})\n'.format(message)
self.result.append(message)
print self.result
def catch_new_tokens(self):
tmp = self.pattern
arr_tokens = tmp[tmp.find('(') + 1 : tmp.find(')')].split(',')
for token in arr_tokens:
if self.is_int(token):
self.tokens.append(token)
def is_int(self, entry):
try:
int(entry)
return True
except ValueError:
return False
class IncognitoOldVersion:
def __init__(self):
pass
def set_file(self, incognito_file):
self.file = incognito_file
def set_pattern(self, pattern):
self.pattern = pattern
def main():
STREAMER_OBJECT_SD = 10 #Valor que vocк irб utilizar por padrгo em todos os objetos convertidos
STREAMER_OBJECT_DD = 10 #Valor que vocк irб utilizar por padrгo em todos os objetos convertidos
OBJECTS_FILE_REF = 'nome.txt' #Path do arquivo que contйm todos os objetos que vocк deseja converter
conversor = IncognitoConverter('CreateDynamicObject(id, x, y, z, rx, ry, rz, -1, -1, -1, {}, {})'.format(STREAMER_OBJECT_SD, STREAMER_OBJECT_DD))
old_version = IncognitoOldVersion()
old_version.set_file(OBJECTS_FILE_REF)
old_version.set_pattern('CreateDynamicObject(id, x, y, z, rx, ry, rz)')
conversor.cast_process(old_version)
print 'Objeto convertido com sucesso!'
main()
python main.py
OBJECTS_FILE_REF = 'nome.txt' #Path do arquivo que contйm todos os objetos que vocк deseja converter