Scripting Puzzle of the Day

Discussion in 'General Modification' started by Firestrand, Apr 6, 2005.

Remove all ads!
  1. Firestrand

    Firestrand Member

    Joined:
    Mar 11, 2004
    Messages:
    79
    Likes Received:
    0
    Ok, I was looking into the pickle routine a little more, and found a reference to __getstate__() being called on an object. So I decided to give it a try, and sure enough I get a little something, I was hoping to be able to use this to get a handle on the items, but I am not sure what to do with what was returned? I suspect they are pointers to different things, but I don't know how to do the magic necessary in python to get anything usefull from them.

    Does anyone else?

    try:
    game.party[0].__getstate__()

    *note: There are two underscores before and after getstate.

    -Firestrand
     
    Last edited: Apr 7, 2005
  2. dulcaoin

    dulcaoin Established Member Veteran

    Joined:
    Mar 10, 2005
    Messages:
    213
    Likes Received:
    0
    He means "underscores", rather than "spaces" <wink>

    (not near my rig today, can't test the call yet)

    -- dulcaoin
     
  3. Firestrand

    Firestrand Member

    Joined:
    Mar 11, 2004
    Messages:
    79
    Likes Received:
    0
    Here are all of the built-in modules available with the python interpreter included in ToEE. I have tried to include some of the modules in my python\Lib folder, however things either don't work, or crash the game entirely. I was only trying to get some of the useful features of python like "inspect", it depends on modules, that don't work well with the game interpreter. I wonder if it would work with Python 2.2 scripts? I am currently using 2.4. Anyway, I just wanted to share in case anyone else wants to experiment with the available modules.

    ('__builtin__'
    '__main__'
    '_codecs'
    '_hotshot'
    '_locale'
    '_weakref'
    'array'
    'audioop'
    'binascii'
    'cPickle'
    'cStringIO'
    'cmath'
    'errno'
    'exceptions'
    'gc'
    'imageop'
    'imp'
    'marshal'
    'math'
    'md5'
    'msvcrt'
    'new'
    'nt'
    'operator'
    'pcre'
    'regex'
    'rgbimg'
    'rotor'
    'sha'
    'signal'
    'strop'
    'struct'
    'sys'
    'thread'
    'time'
    'xreadlines'
    'xxsubtype')

    -Firestrand
     
  4. Firestrand

    Firestrand Member

    Joined:
    Mar 11, 2004
    Messages:
    79
    Likes Received:
    0
    Yep, installing python 2.2.3 gets things working well. Now the python files are loaded automagically from my python22 directory.

    I found one problem, you must set a variable in "re.py" to engine = "pre" otherwise the game will crash if you import anything that uses the re module.

    Anyway, get your copy of python 2.2.3, and get commandline access to more python tools in the game.

    If you should happen to run into any other python modules that crash post them and / or the fixes here.

    -Firestrand
     
  5. dulcaoin

    dulcaoin Established Member Veteran

    Joined:
    Mar 10, 2005
    Messages:
    213
    Likes Received:
    0
    Could you be a little more specific about the steps required? That would help.

    -- d
     
  6. Firestrand

    Firestrand Member

    Joined:
    Mar 11, 2004
    Messages:
    79
    Likes Received:
    0
    Sure.
    1. Install python 2.2.3
    2. in the python22\Lib folder open re.py in a text editor
    3. comment out the line that reads
    Code:
    engine = "sre"
    4. uncomment the line that reads
    Code:
    #engine = "pre"
    The code should now look like
    Code:
    #engine = "sre"
    engine = "pre"
    5. save re.py and exit your text editor

    That should do it, when you start ToEE it will automagically pick up the python22 directory and Lib directory into the sys.path, you will now have access to all of the python22 modules.

    Of course if you are like me, one of the first things you will discover is that none of the things built in to temple.dll have python bytecode available.

    If that isn't clear enough, or if something doesn't work let me know.

    -Firestrand
     
Our Host!