EnglishGermanFrenchRussianItalianSpanish
Log inRegister
 
[TOOL] Copy Universe Aesthetics (BG, Sun, Planet)
Post new topic Reply to topic
View previous topic :: View next topic
Author Message
Jack08





Joined: 25 Dec 2005
Posts: 2970 on topic
Location: Australia
Thank you for registering your game
PostPosted: Fri, 16. Dec 11, 18:11    Post subject: [TOOL] Copy Universe Aesthetics (BG, Sun, Planet) Reply with quote Print

To Copy all background, sun and planet data from one universe file to another universe file, follow these instructions:

  • Step1: Install Python 2.7 from http://www.python.org (do not use 3.x)
  • Step2: Create a new folder anwhere on your computer and name it anything you like
  • Step3: Create the following file: "CopyAesthetics.py" and copy and paste the script below into this file
  • Step4: Extract and place the Universe XML witch holds the visual data you want to copy in the same folder as the python script and name it "x3_universe_source.xml"
  • Step5: Extract the Universe XML witch you would like to input visual data to and place it in the same fodler as the python script and name it "x3_universe_target.xml"
  • Step6: Execute(Double Click) the script, A "x3_universe_output.xml" file should be created
  • Step7: Rename the "x3_universe_output.xml" file to "x3_universe.xml"
  • Step8: ???
  • Step9: Profffffit!


Provided without warranty.

CopyAesthetics.py:
Code:
#Written by Jack08
SourceXML = open("x3_universe_source.xml", "r")

def ExtractElement(Element, Data):
    Element = Element+"="
    A = Data.split(Element)
    if len(A) > 1:
        A=A[1]
        A=A.split('"')[1]
        return A
    return False


def IsTypeNonF(Type, Data):
    Chk = ExtractElement("t", Data)
    if Chk == False or Chk != str(Type) or ExtractElement("f", Data)!=False:
        return False
    return Chk

def IsType(Type, Data):
    Chk = ExtractElement("t", Data)
    if Chk == False or Chk != str(Type):
        return False
    return Chk

def IsSector(Data):
    return IsType(1, Data)

def IsSun(Data):
    return IsTypeNonF(3, Data)

def IsBackground(Data):
    return IsType(2, Data)

def IsPlanet(Data):
    return IsType(4, Data)

Data = SourceXML.readline()
Sectors = []
cSector = []

while Data != '':
    if(IsSector(Data)):
        if len(cSector):
            Sectors.append(cSector)
        cSector = []
        A=Data
        cSector.append([int(ExtractElement("x", Data)), int(ExtractElement("y", Data))])   
    if(IsBackground(Data) or IsSun(Data) or IsPlanet(Data)):
        cSector.append(Data)
    Data = SourceXML.readline()

SourceXML.close()



XML_OUT = []
Target = open("x3_universe_target.xml", "r")
Data = Target.readline()

Enable = False

while Data != '':
    if(IsSector(Data)):
        XML_OUT.append(Data)
        CoOrd = [int(ExtractElement("x", Data)), int(ExtractElement("y", Data))]
        for Entry in Sectors:
            if CoOrd in Entry:
                for NewData in Entry:
                    if type(NewData) == str:
                        XML_OUT.append(NewData)
                Enable = True
                break
            else:
                Enable = False
        Data = Target.readline()
        continue

    if((IsBackground(Data) or IsSun(Data) or IsPlanet(Data)) and Enable):
        Data = Target.readline()
        continue

    XML_OUT.append(Data)
    Data = Target.readline()
   
Target.close()

Output = open("x3_universe_output.xml", "w")
for Element in XML_OUT:
    Output.write(Element)
Output.close()





_________________

"One sure mark of a fool is to dismiss anything that falls outside his experience as being impossible."
―Farengar Secret-Fire
Back to top
View user's profile Send private message
Ketraar
Moderator (PortuguÍs)
Moderator (PortuguÍs)

MEDALMEDAL

Joined: 21 May 2004
Posts: 8534 on topic
Location: Guimar„es (Portugal)
Thank you for registering your game
PostPosted: Fri, 16. Dec 11, 20:32    Post subject: Reply with quote Print

Mind that in AP some objects are placed by x3universe_war.xml.

Just heads up Wink

MFG

Ketraar

Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic Reply to topic
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum
Control Panel
Login Data
The time now is Fri, 20. Jul 18, 08:21

All times are GMT + 2 Hours

[ Disclaimer / Impressum ] | [ Privacy Policy / Datenschutz ]

Board Security

Copyright © EGOSOFT 1989-2018
Powered by phpBB © 2001, 2005 phpBB Group
Template created by Avatar & BurnIt!
Debug: page generation = 0.05789 seconds, sql queries = 16