Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Debugger (https://forums.graalonline.com/forums/showthread.php?t=134257103)

adam 03-01-2010 12:30 AM

I was kinda thinking of copying another certain 2d sidescrolling mmorpg, only better

fowlplay4 09-26-2010 07:18 PM

Updated with simple remote debugging support, and changed some internal debugger function names.

PHP Code:

/*
   Core Debugger Functions: 
   
     Avoid overwriting these functions in your scripts.
   
     - initializeDebugger()
     - createDebuggerGUI(title)
     - changeDebuggerScope(obj)
     - debuggerCall(obj)
     - resumeDebuggingCode(obj)
     - onResumingCode()
   
   Debugging Functions:
   
     Call these in your scripts to use the debugger.
   
     - debug_breakPoint(temp.time)
     - debug_updateVariables(temp.scope)
     
   Remote Debugging (Echos):
   
     Set this.remotedebugging to true in your script
     and clientside echos will be sent to RC.
   
*/

function onActionServerSide() {
  switch (
params[0]) {
    case 
"debugger_echo":
      echo(
params[1]);
      break;
  }
}

//#CLIENTSIDE

function onCreated() {
  
// Control Debug Access
  
temp.debuggers = {
    
"fowlplay4"
  
};
  if (
player.account in temp.debuggers) {
    
initializeDebugger();
  }
}

function 
initializeDebugger() {
  
// Initialize Debugger GUI
  
createDebuggerGUI(this.name);
}

function 
createDebuggerGUI(title) {
  
// Creates Simple Debugger GUI
  
new GuiWindowCtrl("Debugger_" title) {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "173,262";
    
canmove true;
    
canresize false;
    
closequery false;
    
canminimize canmaximize false;
    
destroyonhide true;
    
visible true;
    
text "Debugging:" SPC title;
    
screenwidth 200;
    
7;

    new 
GuiTextCtrl("Debugger_" title "Text1") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Variables";
      
width 46;
      
11;
    }
    new 
GuiScrollCtrl("Debugger_" title "_Scroll") {
      
profile GuiBlueScrollProfile;
      
height 192;
      
hscrollbar "alwaysOff";
      
vscrollbar "dynamic";
      
width 163;
      
5;
      
19;
      new 
GuiTextListCtrl("Debugger_" title "_List") {
        
profile GuiBlueTextListProfile;
        
height 32;
        
horizsizing "width";
        
width 159;
        
temp.varlist this;
      }
    }
    new 
GuiTextEditCtrl("Debugger_" title "_Scope") {
      
profile GuiBlueTextEditProfile;
      
height 20;
      
width 126;
      
42;
      
214;
      
this.varslist temp.varlist;
      
thiso.catchevent(name"onAction""onChangeDebuggerScope");
      
hint "Press enter to change debugger's variable scope.";
    }
    new 
GuiTextCtrl("Debugger_" title "_Text2") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Scope";
      
width 31;
      
7;
      
213;
    }
    new 
GuiTextCtrl("Debugger_" title "_Text3") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Call";
      
width 17;
      
11;
      
238;
    }
    new 
GuiTextEditCtrl("Debugger_" title "_Call") {
      
profile GuiBlueTextEditProfile;
      
height 20;
      
width 126;
      
42;
      
239;
      
thiso.catchevent(name"onAction""debuggerCall");
      
hint "Press enter to call a certain function in the script.";
    }
  }
  
// Populate Variable List
  
debug_updateVariables("this.");
}

function 
onChangeDebuggerScope(obj) {
  
// Clear List
  
temp.list = obj.varslist;
  
temp.list.clearrows();
  
// Determine Scope
  
temp.scope obj.text;
  
temp.scope temp.scope.ends(".") ? temp.scope : (temp.scope ".");
  
// Locate Variables
  
temp.variablez getstringkeys(temp.scope);
  
// Determine Functions
  
temp.functionz this.getfunctions();
  
// List Variables
  
for (temp.var: variablez) {
    
// Filter out Functions
    
if (temp.var in temp.functionz) continue;
    
// Get Value of Variable
    
temp.value makevar(temp.scope temp.var);
    
// Add Row to Variable List
    
temp.row = list.addrow(0format("%s%s: %s"temp.scopetemp.var, temp.value));
    
temp.row.hint temp.value;
  }
}

function 
debuggerCall(obj) {
  
// Determine Call
  
temp.call obj.text;
  
// Call Object
  
if (call.starts("on")) this.trigger(call.substring(2), "");
  else 
this.(@call)();
}

function 
resumeDebuggingCode(obj) {
  
// Decrease Window Size
  
with (makevar("Debugger_" thiso.name)) {
    
height -= 32;
  }
  
// Destroy Button
  
obj.destroy();
  
// Resume Code
  
this.trigger("onResumingCode""");
}

/*
   Halts the script and places the resume button on the
   debugger.
   
   temp.time - The length in seconds to halt script for.
               If unspecified, defaults to 24 hours.
*/

function debug_breakPoint(temp.time) {
  
// Check for Debugger Window
  
if (!isObject("Debugger_" this.name)) return;
  
// Create Resume Button 
  
with (makevar("Debugger_" this.name)) {
    if (!
isObject("Debugger_" thiso.name "_Resume")) {
      
height += 32;
      new 
GuiButtonCtrl("Debugger_" thiso.name "_Resume") {
        
4;
        
239 22;
        
width 164;
        
text "Resume Code";
        
profile "GuiBlueButtonProfile";
        
thiso.catchevent(name"onAction""resumeDebuggingCode");
      }
    }
  }
  
// Update Variable List based on Scope
  
debug_updateVariables();
  
// Begin Wait
  
waitfor(this"onResumingCode", (temp.time temp.time 3600 24));
}

/*
   Updates the variable list.
   
   temp.scope - If specified it overwrites the scope in
                the text box, and updates accordingly.
*/

function debug_updateVariables(temp.scope) {
  
// Determine Scope Object
  
temp.obj_scope makevar("Debugger_" this.name "_Scope");
  
// Update Scope Text if neccesary
  
temp.obj_scope.text temp.scope temp.scope temp.obj_scope.text;
  
// Update Variable List
  
onChangeDebuggerScope(temp.obj_scope);
}

function echo(
str) {
  if (
this.remotedebugging) {
    
triggerserver("gui"name"debugger_echo"str);
  }




All times are GMT +2. The time now is 12:57 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.