Python
From Alcugs
Contents |
Introduction
This topic is not about programming Python in general. For that, you can find excellent tutorials at www.python.org . All Python programming must be done using Python v.2.2.3, as this is the version Cyan used. It is available for free download from www.python.org .
File Types
.py are Python source files.
.pyc are compiled Python files.
.pak are archives of .pyc files. They are encrypted.
Decompiling Uru Python Files
To decompile Uru Python files, you can use 1 of 2 programs:
UruPython3.1 available at huru.aegura.com
UruPython1.2 available at mystv.aegura.com
UruPython3.1 has a GUI, but may have problems decompiling some files. UruPython1.2 is command prompt, but I have had no problems with it. Both programs use Decompyle v. 2.2
First you must unpack whichever .pak file you want. This will give you several hundred .pyc files. This must then be decompiled into .py files. These can then be edited using any text editer.
Compiling Python Files
To compile Python files, you will want to put the file you want to compile into a folder with all the files that are used by Uru(I don't think it matters if they are .pyc?). Then type "python compileall.py"(or "python compileall.pyc?). This will then compile all files in the directory, including yours. Note that if python is not in the search path, you will have to type the path to it.
Copy only the files you have created to a directory. Then you can use UruPython3.1 or UruPython1.2 to repack and encrypt the .pyc files you have created.
Behavior of .pak Files
All of the .pyc files in all of the .pak files behave as though they were in a single directory. They can access each other accross different .pak files perfectly well. If 2 .pyc files with the same name are present in different .pak files, then the one whose .pak file has the most recent date will be used. This allows us to override a .pyc file, without overwriting it.
Typical Layout .py Files
Typically, a .py files has:
- from module import *, import module block.
- global variables.
- attributes, which are how you communicate with the .age and .prp files.
- a class that has the same name of the file, which is perhaps the same name as the Age.
- a "glue" appendix, which is apparently identical for all files(and isn't needed?).
The class is decended from ptResponder: e.g.
class RestorationGuild(ptResponder,):
__module__ = __name__
def __init__(self):
ptResponder.__init__(self)
self.id = 5322
self.version = 1
It may contain built in methods such as:
def OnNotify(self, state, id, events): def OnServerInitComplete(self): def OnSDLNotify(self, VARname, SDLname, PlayerID, tag): def OnTimer(self, id):

