.pyc files

Discussion in 'General Modification' started by Zebedee, Jul 16, 2006.

Remove all ads!
  1. Zebedee

    Zebedee Veteran Member Veteran

    Joined:
    Apr 2, 2005
    Messages:
    1,755
    Likes Received:
    0
    Just a quick question about .pyc files:

    why do some open in notepad without a problem and others display ASCII (?) characters when opened?

    I'm trying to fiddle with Lubash to correct something which has always irritated me (and as a way to practice) but before I do it I need to know what the file already altered for Co8 is doing. :)

    Thanks in advance.

    Zeb
     
  2. Agetian

    Agetian Attorney General Administrator

    Joined:
    Aug 14, 2004
    Messages:
    2,526
    Likes Received:
    0

    .py = Python source files
    .pyc = Python compiled files

    PYC files should never be opened directly in a text editor. Instead, you should open the PY file which is the source one. PYCs get compiled from PY by the in-game Python compiler in order to optimize their execution speed.

    - Agetian
     
  3. Zebedee

    Zebedee Veteran Member Veteran

    Joined:
    Apr 2, 2005
    Messages:
    1,755
    Likes Received:
    0
    Thanks Agetian.

    So that would mean there has been no Co8 work done on Lubash .py file then if it isn't present in the Co8 data files I take it? Cool :)
     
  4. rufnredde

    rufnredde Established Member Veteran

    Joined:
    Apr 8, 2006
    Messages:
    266
    Likes Received:
    1
    Well Zeb

    .py file is a text file more or less, it is the actual python code, so it is formatted but it is still in english more or less.

    .pyc files are binary files on the other hand, .py files compiled into machine code.

    So the real difference is that one is for humans and the other for computers to read.

    .py extension = python code
    .pyc extension = compiled python code

    All of the source code or .py files are either in the data\scr directory or hidden away in the .dat files in toee3.dat or toee4.dat, makes no difference which ones you use as far as the .dat files go they are mirror images of each other.

    If there is only a .pyc file in the data\scr directory of your toee root. It means that the .py file only exists in the .dat file. The game automatically stores the .pyc files in that directory as it compiles them. It also means that the .py file for Lubash has never been modded by Co8.

    To work with it just copy the .py file from the extracted .dat file into the data\scr directory and edit it with notepad. One a copy exists in the scr directory, the game automatically uses that file instead of the one in the .dat file.

    Hope that answers your question

    Edit: Opps a little slow I see, PM me if you need any help Zeb. I can point out a few common pitfalls to watch out for when your just starting out.
     
    Last edited: Jul 16, 2006
  5. Zebedee

    Zebedee Veteran Member Veteran

    Joined:
    Apr 2, 2005
    Messages:
    1,755
    Likes Received:
    0
    Thanks ruf. Between you, Agetian, Blue and Shiningted there may be hope for me yet ;)

    The answers, as usual, have been perfect. I can now try and see if I can get Lubash to actually talk to the party leader (providing s/he is within range) rather than a random player character without worrying about whether someone has done something very clever which I will fubar up without ever realising it.
     
  6. Gaear

    Gaear Bastard Maestro Administrator

    Joined:
    Apr 27, 2004
    Messages:
    11,029
    Likes Received:
    42
    That'd be great Zeb. Lubash has dialogue that most people never hear when he simply attacks on sight.
     
  7. Zebedee

    Zebedee Veteran Member Veteran

    Joined:
    Apr 2, 2005
    Messages:
    1,755
    Likes Received:
    0
    It happens with a lot of encounters and is really irritating as the way the party move cannot be legislated for properly due to pathing. eg The gnoll leader does the same thing.
     
  8. Agetian

    Agetian Attorney General Administrator

    Joined:
    Aug 14, 2004
    Messages:
    2,526
    Likes Received:
    0
    @ Zebedee: if you have a .pyc file but don't see a .py file doesn't mean the .py file doesn't exist. ;) A .pyc file is created by the game based on an existing .py file, so you've got to search inside the .dats for the original Python source.

    Hope this helps.
    - Agetian
     
  9. Zebedee

    Zebedee Veteran Member Veteran

    Joined:
    Apr 2, 2005
    Messages:
    1,755
    Likes Received:
    0
    Thanks Agetian - this is why I've been playing with your DAT tool ;)


    edit:

    Hmm. Looks like I'm going to need a bit of grounding in Python if I'm not going to turn into Orion. Can anyone recommend a good public domain source for python scripting basics? Something like a free website with tutorials? Or is that too much to hope for? I need something just to explain how the scripting actually functions, how the way you input things changes what happens, stuff like that :)
     
    Last edited: Jul 17, 2006
Our Host!