Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #16  
Old 03-01-2010, 12:30 AM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
I was kinda thinking of copying another certain 2d sidescrolling mmorpg, only better
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
  #17  
Old 09-26-2010, 07:18 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
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);
  }

__________________
Quote:
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 02:36 PM.


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