Update dbg.py to lastest version
This commit is contained in:
		
							parent
							
								
									8830340b8b
								
							
						
					
					
						commit
						f8bc746132
					
				
					 1 changed files with 214 additions and 77 deletions
				
			
		
							
								
								
									
										291
									
								
								lib/dbg.py
									
										
									
									
									
								
							
							
						
						
									
										291
									
								
								lib/dbg.py
									
										
									
									
									
								
							|  | @ -2,101 +2,192 @@ import sys | ||||||
| import Scrap | import Scrap | ||||||
| import quickconsole | import quickconsole | ||||||
| import MissionsFuncs | import MissionsFuncs | ||||||
| QC=quickconsole | import SScorer | ||||||
| MF=MissionsFuncs | import Menu | ||||||
|  | QC = quickconsole | ||||||
|  | MF = MissionsFuncs | ||||||
|  | last_frame = None | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | def reload(): | ||||||
|  |     sys.settrace(None) | ||||||
|  |     sys.modules['__builtin__'].reload(sys.modules['dbg']) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | def dgb_info(): | ||||||
|  |     txt =`last_frame` | ||||||
|  |     SScorer.SetLabelText(txt, Scrap.GetTime()+0.1) | ||||||
|  |     Scrap.AddScheduledFunc(Scrap.GetTime()+0.1, dgb_info, (), "dbg_info") | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | def crazy(): | ||||||
|  |     E = Scrap.GetFirst() | ||||||
|  |     me = Scrap.UsrEntity(0) | ||||||
|  |     while E: | ||||||
|  |         if E.Name == me.Name: | ||||||
|  |             E = Scrap.GetEntity(E.NextInSlot) | ||||||
|  |         try: | ||||||
|  |             E.Action = "CrazyInit" | ||||||
|  |             E.CanPhoto = 1 | ||||||
|  |             E.DefLoop = "Crazy" | ||||||
|  |         except: | ||||||
|  |             pass | ||||||
|  |         E = Scrap.GetEntity(E.NextInSlot) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | def decrazy(): | ||||||
|  |     E = Scrap.GetFirst() | ||||||
|  |     me = Scrap.UsrEntity(0) | ||||||
|  |     while E: | ||||||
|  |         if E.Name == me.Name: | ||||||
|  |             E = Scrap.GetEntity(E.NextInSlot) | ||||||
|  |         try: | ||||||
|  |             E.Action = "CrazyEnd" | ||||||
|  |             E.CanPhoto = 0 | ||||||
|  |             E.ForceDefLoop = "Relax" | ||||||
|  |         except: | ||||||
|  |             pass | ||||||
|  |         E = Scrap.GetEntity(E.NextInSlot) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| def p_s(*args): | def p_s(*args): | ||||||
|     msg="" |     msg = "" | ||||||
|     for obj in args: |     for obj in args: | ||||||
|         if msg: |         if msg: | ||||||
|             msg=msg+" "+str(obj) |             msg = msg+" "+str(obj) | ||||||
|         else: |         else: | ||||||
|             msg=msg+str(obj) |             msg = msg+str(obj) | ||||||
|     Scrap.Print(msg) |     Scrap.Print(msg) | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| def p_e(*args): | def p_e(*args): | ||||||
|     msg="" |     msg = "" | ||||||
|     for obj in args: |     for obj in args: | ||||||
|         if msg: |         if msg: | ||||||
|             msg=msg+" "+str(obj) |             msg = msg+" "+str(obj) | ||||||
|         else: |         else: | ||||||
|             msg=msg+str(obj) |             msg = msg+str(obj) | ||||||
|     Scrap.ConsoleError(msg) |     Scrap.ConsoleError(msg) | ||||||
| sys.stdout.write=p_s | 
 | ||||||
| sys.stderr.write=p_e | 
 | ||||||
|  | sys.stdout.write = p_s | ||||||
|  | sys.stderr.write = p_e | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| def p(*args): | def p(*args): | ||||||
|     msg="" |     msg = "" | ||||||
|     for obj in args: |     for obj in args: | ||||||
|         if msg: |         if msg: | ||||||
|             msg=msg+" "+str(obj) |             msg = msg+" "+str(obj) | ||||||
|         else: |         else: | ||||||
|             msg=msg+str(obj) |             msg = msg+str(obj) | ||||||
|     Scrap.Print(msg+"\n") |     Scrap.Print(msg+"\n") | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| def e(*args): | def e(*args): | ||||||
|     msg="" |     msg = "" | ||||||
|     for obj in args: |     for obj in args: | ||||||
|         if msg: |         if msg: | ||||||
|             msg=msg+" "+str(obj) |             msg = msg+" "+str(obj) | ||||||
|         else: |         else: | ||||||
|             msg=msg+str(obj) |             msg = msg+str(obj) | ||||||
|     Scrap.ConsoleError(msg+"\n") |     Scrap.ConsoleError(msg+"\n") | ||||||
| #sys.modules['__builtin__'].__dict__['print']=e | 
 | ||||||
| sys.modules['__builtin__'].__dict__['s_write']=p | 
 | ||||||
| sys.modules['__builtin__'].__dict__['e_write']=e | # sys.modules['__builtin__'].__dict__['print']=e | ||||||
|  | sys.modules['__builtin__'].__dict__['s_write'] = p | ||||||
|  | sys.modules['__builtin__'].__dict__['e_write'] = e | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | def modhelp(Module="Scrap"): | ||||||
|  |     print "======== [ " + Module + " ] ========" | ||||||
|  |     exec("import "+Module) | ||||||
|  |     for v in dir(eval(Module)): | ||||||
|  |         if v in ("__doc__", "__name__"): | ||||||
|  |             continue | ||||||
|  |         print v + ":" | ||||||
|  |         try: | ||||||
|  |             print "      " + eval(Module + "." + v + ".__doc__") | ||||||
|  |         except: | ||||||
|  |             pass | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | def helpfunc(func): | ||||||
|  |     print func.__name__+":" | ||||||
|  |     print "    "+func.__doc__ | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| for module in sys.builtin_module_names: | for module in sys.builtin_module_names: | ||||||
|     if module[0]=="S": |     if module[0] == "S": | ||||||
|         print "Loading "+module |         print "Loading "+module | ||||||
|     exec("import "+module) |     exec("import " + module) | ||||||
| 
 | 
 | ||||||
| sys.settrace(None) | sys.settrace(None) | ||||||
| 
 | 
 | ||||||
| def trace(frame,event,arg): | 
 | ||||||
|     if event!="call": return | def trace(frame, event, arg): | ||||||
|     g=frame.f_globals |     global last_frame | ||||||
|     l=frame.f_locals |     if event != "call": | ||||||
|     if frame.f_code.co_name=="godcall": |  | ||||||
|         return |         return | ||||||
|     R=frame.f_code.co_filename+"."+frame.f_code.co_name+"(" |     g = frame.f_globals | ||||||
|  |     l = frame.f_locals | ||||||
|  |     if frame.f_code.co_name == "godcall": | ||||||
|  |         return | ||||||
|  |     if frame.f_code.co_filename == ".\\lib\\dbg.py": | ||||||
|  |         return | ||||||
|  |     R = frame.f_code.co_filename+": "+frame.f_code.co_name+"(" | ||||||
|     for i in range(frame.f_code.co_argcount): |     for i in range(frame.f_code.co_argcount): | ||||||
|         name = frame.f_code.co_varnames[i] |         name = frame.f_code.co_varnames[i] | ||||||
|         R=R+name+"="+repr(frame.f_locals[name])+"," |         R = R+name+"="+repr(frame.f_locals[name])+"," | ||||||
|     R=R+") Consts: [" |     R = R+") Consts: [" | ||||||
|     for const in frame.f_code.co_consts: |     for const in frame.f_code.co_consts: | ||||||
|         R=R+repr(const)+"," |         R = R+repr(const)+"," | ||||||
|     R=R+"]" |     R = R+"]" | ||||||
|     log(R) |     print R, "Locals:", l, "Globals:", g | ||||||
|  |     last_frame = R | ||||||
|     return trace |     return trace | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| def menu(): | def menu(): | ||||||
|     import Menu |     import Menu | ||||||
|     Menu.DebugMenu(0,'') |     Menu.DebugMenu(1, '') | ||||||
|     Menu.InitMenuSys(0) |     Menu.InitMenuSys(1) | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| def settrace(): | def settrace(): | ||||||
|     sys.settrace(trace) |     sys.settrace(trace) | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | def notrace(): | ||||||
|  |     sys.settrace(None) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| def log(*args): | def log(*args): | ||||||
|     if not args: |     if not args: | ||||||
|         open(logfile_name,"w").close() |         open(logfile_name, "w").close() | ||||||
|         return |         return | ||||||
|     msg="" |     msg = "" | ||||||
|     for obj in args: |     for obj in args: | ||||||
|         if msg: |         if msg: | ||||||
|             msg=msg+" "+str(obj) |             msg = msg+" "+str(obj) | ||||||
|         else: |         else: | ||||||
|             msg=msg+str(obj) |             msg = msg+str(obj) | ||||||
|     open(logfile_name,"a").write(msg+"\n") |     open(logfile_name, "a").write(msg+"\n") | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| def helplib(): | def helplib(): | ||||||
|  |     global logfile_name | ||||||
|     print "Generating helplib.txt" |     print "Generating helplib.txt" | ||||||
|  |     logfile_name = "helplib.txt" | ||||||
|     log() |     log() | ||||||
|     for modname,mod in sys.modules.items(): |     for modname, mod in sys.modules.items(): | ||||||
|  |         if hasattr(mod, '__file__'): | ||||||
|  |             continue | ||||||
|         log("======== [ "+modname+" ] ========") |         log("======== [ "+modname+" ] ========") | ||||||
|         for name,value in vars(mod).items(): |         for name, value in vars(mod).items(): | ||||||
|             if name in ("__doc__","__name__"): |             if name in ("__doc__", "__name__"): | ||||||
|                 continue |                 continue | ||||||
|             if hasattr(value,"__doc__"): |             if hasattr(value, "__doc__"): | ||||||
|                 if value.__doc__: |                 if value.__doc__: | ||||||
|                     log("- "+name+":") |                     log("- "+name+":") | ||||||
|                     log("      "+value.__doc__) |                     log("      "+value.__doc__) | ||||||
|  | @ -105,12 +196,18 @@ def helplib(): | ||||||
|             else: |             else: | ||||||
|                 log("- "+name+": "+repr(value)) |                 log("- "+name+": "+repr(value)) | ||||||
|         log("\n") |         log("\n") | ||||||
|  |     logfile_name = None | ||||||
|     print "Done!" |     print "Done!" | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| def enable_all_conv(): | def enable_all_conv(): | ||||||
|     import CharConversor |     try: | ||||||
|     CharConversor.ConversionChars=list(CharConversor.ConversionChars) |         import CharConversor | ||||||
|     E=Scrap.GetFirst() |     except ImportError: | ||||||
|  |         print("CharConversor not available") | ||||||
|  |         return | ||||||
|  |     CharConversor.ConversionChars = list(CharConversor.ConversionChars) | ||||||
|  |     E = Scrap.GetFirst() | ||||||
|     while E: |     while E: | ||||||
|         try: |         try: | ||||||
|             if E.ActCtrl not in CharConversor.ConversionChars: |             if E.ActCtrl not in CharConversor.ConversionChars: | ||||||
|  | @ -118,64 +215,104 @@ def enable_all_conv(): | ||||||
|         except: |         except: | ||||||
|             E = Scrap.GetEntity(E.NextInSlot) |             E = Scrap.GetEntity(E.NextInSlot) | ||||||
|             continue |             continue | ||||||
|         E.Invulnerable=0 |         E.Invulnerable = 0 | ||||||
|         E.Life=100 |         E.Life = 100 | ||||||
|         E = Scrap.GetEntity(E.NextInSlot) |         E = Scrap.GetEntity(E.NextInSlot) | ||||||
|     print(len(CharConversor.ConversionChars)) |     print(len(CharConversor.ConversionChars)) | ||||||
|     print "Done!" |     print "Done!" | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| def goto(name=None): | def goto(name=None): | ||||||
|     if name==None: |     if name == None: | ||||||
|         name=MF.currentTarget |         name = MF.currentTarget | ||||||
|     Scrap.UsrEntity(0).Pos=Scrap.GetEntity(name).Pos |     Scrap.UsrEntity(0).Pos = Scrap.GetEntity(name).Pos | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| def bring(name=None): | def bring(name=None): | ||||||
|     if name==None: |     if name == None: | ||||||
|         name=MF.currentTarget |         name = MF.currentTarget | ||||||
|     Scrap.GetEntity(name).Pos=Scrap.UsrEntity(0).Pos |     Scrap.GetEntity(name).Pos = Scrap.UsrEntity(0).Pos | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| def nuke(): | def nuke(): | ||||||
|     E=Scrap.GetFirst() |     E = Scrap.GetFirst() | ||||||
|     me = Scrap.UsrEntity(0) |     me = Scrap.UsrEntity(0) | ||||||
|     while E: |     while E: | ||||||
|         if E.Name==me.Name: |         if E.Name == me.Name: | ||||||
|             E = Scrap.GetEntity(E.NextInSlot) |             E = Scrap.GetEntity(E.NextInSlot) | ||||||
|         try: |         try: | ||||||
|             E.Life=0 |             E.Life = 0 | ||||||
|             E.Invulnerable=0 |             E.Invulnerable = 0 | ||||||
|         except: |         except: | ||||||
|             pass |             pass | ||||||
|         E = Scrap.GetEntity(E.NextInSlot) |         E = Scrap.GetEntity(E.NextInSlot) | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| def become(name): | def become(name): | ||||||
|     enable_all_conv() |     enable_all_conv() | ||||||
|     import CharConversor |     import CharConversor | ||||||
|     me = Scrap.UsrEntity(0) |     me = Scrap.UsrEntity(0) | ||||||
|     ent = Scrap.GetEntity(name) |     ent = Scrap.GetEntity(name) | ||||||
|     if ent: |     if ent: | ||||||
|         CharConversor.Possession(me.Name,name) |         CharConversor.Possession(me.Name, name) | ||||||
|     else: |     else: | ||||||
|         print "Entity not found" |         print "Entity not found" | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| StopMovie = 0 | StopMovie = 0 | ||||||
| 
 | 
 | ||||||
| def movie(MovieName="Movie/Movie"): |  | ||||||
| 	global StopMovie |  | ||||||
| 	if LastTime==None: |  | ||||||
| 		Scrap.Set( "PhysicalAspectRatio", 16.0/9.0 ) |  | ||||||
| 		LastTime = Scrap.GetTime() |  | ||||||
| 		StopMovie = 0 |  | ||||||
| 	if StopMovie == 1: |  | ||||||
| 		return |  | ||||||
| 	Scrap.Set("DisableSkipSlot",1) |  | ||||||
| 	Scrap.ProcessDVF(MovieName+".dvf",0) |  | ||||||
| 	Scrap.ScreenShot(MovieName+"*") |  | ||||||
| 	NextTime = LastTime+1.0/25.0 |  | ||||||
| 	Scrap.AddScheduledFunc(NextTime,movie,(Speed,MovieName,NextTime)) |  | ||||||
| 
 | 
 | ||||||
| logfile_name="helplib.txt" | def movie(MovieName="Movie/Movie"): | ||||||
|  |     global StopMovie | ||||||
|  |     if LastTime == None: | ||||||
|  |         Scrap.Set("PhysicalAspectRatio", 16.0/9.0) | ||||||
|  |         LastTime = Scrap.GetTime() | ||||||
|  |         StopMovie = 0 | ||||||
|  |     if StopMovie == 1: | ||||||
|  |         return | ||||||
|  |     Scrap.Set("DisableSkipSlot", 1) | ||||||
|  |     Scrap.ProcessDVF(MovieName+".dvf", 0) | ||||||
|  |     Scrap.ScreenShot(MovieName+"*") | ||||||
|  |     NextTime = LastTime+1.0/25.0 | ||||||
|  |     Scrap.AddScheduledFunc(NextTime, movie, (Speed, MovieName, NextTime)) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | def park(): | ||||||
|  |     me = Scrap.UsrEntity(0) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | def find(filt="*"): | ||||||
|  |     Scrap.StartDummySearch(filt, 1) | ||||||
|  |     dummy = 1 | ||||||
|  |     while dummy: | ||||||
|  |         dummy = Scrap.NextDummySearch() | ||||||
|  |         print dummy | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | def getall(): | ||||||
|  |     E = Scrap.GetFirst() | ||||||
|  |     me = Scrap.UsrEntity(0) | ||||||
|  |     while E: | ||||||
|  |         try: | ||||||
|  |             E.Pos = me.Pos | ||||||
|  |         except: | ||||||
|  |             pass | ||||||
|  |         E = Scrap.GetEntity(E.NextInSlot) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | def god(): | ||||||
|  |     e = Scrap.UsrEntity(0) | ||||||
|  |     QC.godcall(None, (1, 1, 1, 1, 1, 1)) | ||||||
|  |     Scrap.AddScheduledFunc(Scrap.GetTime()+0.1, god, (), 'dbg.god') | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | notrace() | ||||||
| helplib() | helplib() | ||||||
| logfile_name="dbg.txt" | # settrace() | ||||||
| log() | dgb_info() | ||||||
| quickconsole.god() | enable_all_conv() | ||||||
| print "Godmode active" | god() | ||||||
|  | Scrap.Set("debug", 3) | ||||||
|  | Scrap.Set("ShowConsoleLog", 1) | ||||||
|  | 
 | ||||||
|  | print "Debug Module loaded" | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue