Jump to content

Refresh *.py in game


Recommended Posts

# 1.) Search in game.py:

onPressKeyDict[app.DIK_F4]    = lambda : self.__PressQuickSlot(7)

 

# 2.) Add below:

onPressKeyDict[app.DIK_F5]        = lambda : self.LoadScript()

 
def LoadScript(self):
	        import mtdbg
	        mtdbg.LoadMichaFile("files_work_1.py", "NameClassWindow")

 

Add in root new files mtdbg.py and he added:

import ui
	import imp as micha_imp
	global actual_michabg_files
	actual_michabg_files = {}

class LoadMichaFile(ui.ScriptWindow):
    def __init__(self, micha_f, micha):
        global actual_michabg_files
        ui.ScriptWindow.__init__(self)
        self.Show()
        k = micha_f + "|"+ micha 
        if(actual_michabg_files.has_key(k)):
            if(actual_michabg_files[k] != None):
                actual_michabg_files[k].Hide()
                actual_michabg_files[k] = None
        self.s = micha_imp.load_source(micha, micha_f)
        self._c= getattr(self.s, micha)()
        self._c.Show()
        actual_michabg_files[k] = self._c
        print "Reloaded "+ micha_f + "." + micha

    def __del__(self):
        ui.ScriptWindow.__del__(self)

 

Example of use:

Put the script you want to edit root client and rename it in files_work_1.py then enter and edit your class like:

    class NameClassWindow(ui.BoardWithTitleBar): # --* NEW

 

Thanks to @Micha aka xCPx

 

 

  • Love 1
Link to comment
Share on other sites

0512 15:18:23474 :: SYSERR:   File "networkModule.py", line 237, in SetGamePhase

0512 15:18:23475 :: SYSERR:   File "system.py", line 130, in __pack_import

SYSERR:   File "
SYSERR: <string>
SYSERR: ", line
SYSERR: 2141
SYSERR:

SYSERR:
SYSERR: mtdbg.LoadMichaFile("test.py", "Test")

Okey, solved - wrong tabs, but now other problem. When i click F5:

0512 19:27:38201 :: importing from pack mtdbg
0512 19:27:38203 :: SYSERR: Traceback (most recent call last):

0512 19:27:38204 :: SYSERR:   File "game.py", line 1206, in OnKeyDown

0512 19:27:38206 :: SYSERR:   File "game.py", line 339, in <lambda>

0512 19:27:38207 :: SYSERR:   File "game.py", line 316, in LoadScript

0512 19:27:38208 :: SYSERR:   File "system.py", line 130, in __pack_import

0512 19:27:38208 :: SYSERR:   File "
0512 19:27:38209 :: SYSERR: <string>
0512 19:27:38209 :: SYSERR: ", line
0512 19:27:38210 :: SYSERR: 23
0512 19:27:38210 :: SYSERR:

0512 19:27:38211 :: SYSERR:     
0512 19:27:38212 :: SYSERR: ui.ScriptWindow.__del__(self)

 

 

 

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



  • Similar Content

  • Activity

    1. 5

      Effect weapons

    2. 3

      Crystal Metinstone

    3. 3

      Feeding game source to LLM

    4. 113

      Ulthar SF V2 (TMP4 Base)

    5. 3

      Feeding game source to LLM

    6. 0

      Target Information System

    7. 3

      Feeding game source to LLM

    8. 2

      anti exp explanation pls

  • Recently Browsing

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.