Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-09-2011, 08:01 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Post Online Log Reader

I was looking at cbk's login message GUI, and saw that it read the contents of a text file and showed it in a GUI text box. I took this idea and decided to make an online log reader so you can check your logs online. It is just a simple script however and I have thought about adding some more features like editing the text file via a GUI and some other stuff, but I need to read up on editing text files first. Anyway, if you guys think I should go ahead and post it in the code gallery, I will, but I want to see if there is anything you guys think I can improve here. You guys are more than welcome to post edited versions, fixes, advice and whatever else Thanks!
Attached Thumbnails
Click image for larger version

Name:	LogReader.PNG
Views:	264
Size:	21.0 KB
ID:	53341  
Attached Files
File Type: txt LogReader.txt (1.7 KB, 225 views)
__________________
Reply With Quote
  #2  
Old 08-09-2011, 08:10 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
The first thing you need to fix is the terribly inconsistent styling.

Also, you should just use PHP tags for code that's not too long to post.

PHP Code:
function onActionServerSidecmd )
{
  if ( 
cmd == "getLogtext" )
  {
   
temp.l.loadLines"logs/systemmass.txt" );
    
triggerclient"gui"name"returnLogtext"temp.);
    }
    }

//#CLIENTSIDE
function onCreated()
{
triggerserver"gui"name"getLogtext" );
}
function 
showMessagenews )
{
  new 
GuiWindowCtrl("LogReader_Window")
  {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "589,516";
    
isexternal false;

    
canclose true;
    
canmaximize false;
    
canmove true;
    
canresize false;
    
closequery false;
    
destroyonhide false;
    
text "Log Reader";
    
370;
    
72;

    new 
GuiScrollCtrl("LogReader_MultiLine_Scroll")
    {
      
profile GuiBlueScrollProfile;
      
height 504;
      
hscrollbar "dynamic";
      
vscrollbar "dynamic";
      
width 576;
      
6;
      
7;

      new 
GuiMLTextCtrl("LogReader_MultiLine")
      {
        
profile GuiBlueMLTextProfile;
        
height 17;
        
horizsizing "width";
        
plaintext "";
        
text news;
        
width 551;
      }
    }
  }
}
function 
onPlayerChats()
{
if (
player.chat == "/showlog")
{
if(!(
LogReader_Window.visible))
{
LogReader_Window.visible true;
player.chat "";
}
}
if (
player.chat == "/hidelog")
{
if (
LogReader_Window.visible)
{
LogReader_Window.visible false;
player.chat "";
}
}
}


function 
onActionClientSidecmd)
{
  if ( 
cmd == "returnLogtext" )
  {
    for ( 
temp.)
    {
      
temp.ne @= temp."\n";
    }
    
showMessagetemp.ne );
      }
      
setimer(0.05);
}
function 
onWeaponFired()
{
triggerserver"gui"name"getLogtext" );

Cleaned up a bit:

PHP Code:
function onActionServerSide(cmd) {
  if (
cmd == "getLogtext") {
    
temp.l.loadLines("logs/systemmass.txt");
    
triggerclient("gui"name"returnLogtext"temp.l);
  }
}

//#CLIENTSIDE
function onCreated() {
  
triggerserver("gui"name"getLogtext");
}

function 
showMessage(news) {
  new 
GuiWindowCtrl("LogReader_Window") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "589,516";
    
isexternal false;

    
canclose true;
    
canmaximize false;
    
canmove true;
    
canresize false;
    
closequery false;
    
destroyonhide false;
    
text "Log Reader";
    
370;
    
72;

    new 
GuiScrollCtrl("LogReader_MultiLine_Scroll") {
      
profile GuiBlueScrollProfile;
      
height 504;
      
hscrollbar "dynamic";
      
vscrollbar "dynamic";
      
width 576;
      
6;
      
7;

      new 
GuiMLTextCtrl("LogReader_MultiLine") {
        
profile GuiBlueMLTextProfile;
        
height 17;
        
horizsizing "width";
        
plaintext "";
        
text news;
        
width 551;
      }
    }
  }
}

function 
onPlayerChats() {
  if (
player.chat == "/showlog") {
    if (!(
LogReader_Window.visible)) {
      
LogReader_Window.visible true;
      
player.chat "";
    }
  }
  if (
player.chat == "/hidelog") {
    if (
LogReader_Window.visible) {
      
LogReader_Window.visible false;
      
player.chat "";
    }
  }
}


function 
onActionClientSide(cmdl) {
  if (
cmd == "returnLogtext") {
    for (
temp.al) {
      
temp.ne @= temp."\n";
    }
    
showMessage(temp.ne);
  }
  
setimer(0.05);
}

function 
onWeaponFired() {
  
triggerserver("gui"name"getLogtext");

What's with the (misspelled) setTimer command in onActionClientSide?
__________________

Last edited by cbk1994; 08-09-2011 at 08:25 PM..
Reply With Quote
  #3  
Old 08-09-2011, 08:21 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Thank you very much. It was a previous attempt to add a timeout to the script that I decided not to add, but I seem to type too fast and forget to remove things, thank you for spotting it out though. I have added a command to update the log now by saying /updatelog while the log is open instead of firing the weapon allowing you to make the system a hidden weapon.
PHP Code:
function onActionServerSide(cmd) {
  if (
cmd == "getLogtext") {
    
temp.l.loadLines("logs/systemmass.txt");
    
triggerclient("gui"name"returnLogtext"temp.l);
  }
}

//#CLIENTSIDE
function onCreated() {
  
triggerserver("gui"name"getLogtext");
}

function 
showMessage(news) {
  new 
GuiWindowCtrl("LogReader_Window") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "589,516";
    
isexternal false;

    
canclose true;
    
canmaximize false;
    
canmove true;
    
canresize false;
    
closequery false;
    
destroyonhide false;
    
text "Log Reader";
    
370;
    
72;

    new 
GuiScrollCtrl("LogReader_MultiLine_Scroll") {
      
profile GuiBlueScrollProfile;
      
height 504;
      
hscrollbar "dynamic";
      
vscrollbar "dynamic";
      
width 576;
      
6;
      
7;

      new 
GuiMLTextCtrl("LogReader_MultiLine") {
        
profile GuiBlueMLTextProfile;
        
height 17;
        
horizsizing "width";
        
plaintext "";
        
text news;
        
width 551;
      }
    }
  }
}

function 
onPlayerChats() {
  if (
player.chat == "/showlog") {
    if (!(
LogReader_Window.visible)) {
      
LogReader_Window.visible true;
      
player.chat "";
    }
  }
  if (
player.chat == "/hidelog") {
    if (
LogReader_Window.visible) {
      
LogReader_Window.visible false;
      
player.chat "";
    }
  }
  if (
player.chat == "/updatelog") {
    if (
LogReader_Window.visible) {
      
triggerserver("gui"name"getLogtext");
      
player.chat "";
    }
  }
}


function 
onActionClientSide(cmdl) {
  if (
cmd == "returnLogtext") {
    for (
temp.al) {
      
temp.ne @= temp."\n";
    }
    
showMessage(temp.ne);
  }


I ran the styled script by RC and I get errors. I sometimes get this when using java script beautifier.
error: unexpected token: = at line 76: temp.ne@ = temp.a@"\n";
error: unexpected token: at line 79: }
__________________

Last edited by Emera; 08-10-2011 at 11:34 AM..
Reply With Quote
  #4  
Old 08-09-2011, 09:46 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
Quote:
Originally Posted by Emera View Post
I ran the styled script by RC and I get errors. I sometimes get this when using java script beautifier.
error: unexpected token: = at line 76: temp.ne@ = temp.a@"\n";
error: unexpected token: at line 79: }
All you need to do is fix that line, compare the styled version to your original and you'll see the problem.

I personally avoid using @= and similar except for basic math operations like -, +, /, *.
__________________
Quote:
Reply With Quote
  #5  
Old 08-09-2011, 09:59 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Quote:
Originally Posted by fowlplay4 View Post
All you need to do is fix that line, compare the styled version to your original and you'll see the problem.

I personally avoid using @= and similar except for basic math operations like -, +, /, *.
Ah thanks works fine now. Is it worthy of a code gallery thread? I don't know if people will use it so...
__________________
Reply With Quote
  #6  
Old 08-09-2011, 10:33 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
Quote:
Originally Posted by Emera View Post
Ah thanks works fine now. Is it worthy of a code gallery thread? I don't know if people will use it so...
Not really, it doesn't do anything except load a text file nor does it provide any additional features to allow you to go through it more efficiently.

I would personally opt to download a log file through the File Browser and use Notepad++ (or different text editor) to read through it with the additional functionality it provides.

Code Gallery submissions should be (IMO):

1. Documented and styled consistently. (This is very important)
2. Useful, unique, new and/or innovative.
3. Efficient and Scalable (depending on the purpose of the code).
__________________
Quote:
Reply With Quote
  #7  
Old 08-09-2011, 10:43 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Quote:
Originally Posted by fowlplay4 View Post
Not really, it doesn't do anything except load a text file nor does it provide any additional features to allow you to go through it more efficiently.

I would personally opt to download a log file through the File Browser and use Notepad++ (or different text editor) to read through it with the additional functionality it provides.

Code Gallery submissions should be (IMO):

1. Documented and styled consistently. (This is very important)
2. Useful, unique, new and/or innovative.
3. Efficient and Scalable (depending on the purpose of the code).
I agree. I better get back to work and add some more to it then. Perhaps a find function like in the RC Script editor.
__________________
Reply With Quote
  #8  
Old 08-09-2011, 11:12 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
I am applying the new features as we speak. Might take a while because I am going to add as much detail as I can.

New features:
--------------------------------------------------------------------------------------
Filter Text - Choose what text you would like to leave out, or search for specific users.
Copy All - Select all the text in the multi line.
Find Text - Find specific text.
Clear Text - Reset the log file.
Editing and Viewing mode - Allows reading and editing of the text file.
Selection of Log - Allow the selection of the log to read from the GUI.
--------------------------------------------------------------------------------------
I am adding these as I go along and don't yet know if they are all possible, but I will tackle them as I go along. Any help would be greatly appreciated.
Attached Thumbnails
Click image for larger version

Name:	logreaderbeta1.PNG
Views:	234
Size:	200.3 KB
ID:	53343   Click image for larger version

Name:	FindText.PNG
Views:	203
Size:	15.3 KB
ID:	53344  
__________________

Last edited by Emera; 08-10-2011 at 10:02 PM..
Reply With Quote
  #9  
Old 09-16-2012, 10:10 AM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Interesting- does this have lag?
__________________
Reply With Quote
  #10  
Old 09-16-2012, 12:29 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Quote:
Originally Posted by xAndrewx View Post
Interesting- does this have lag?
Oh god X_X
Reply With Quote
  #11  
Old 09-17-2012, 06:01 AM
Raeiphon Raeiphon is offline
I never asked for this.
Join Date: Jun 2005
Posts: 855
Raeiphon is on a distinguished road
you should have a cap on the current amount of loaded lines - if i used this on any of era's logs it'd probably crash the client from the resulting hang
__________________

I hope for nothing. I fear nothing. I am free.
Reply With Quote
  #12  
Old 09-17-2012, 12:54 PM
BlueMelon BlueMelon is offline
asdfg
BlueMelon's Avatar
Join Date: Sep 2008
Posts: 1,481
BlueMelon is a splendid one to beholdBlueMelon is a splendid one to beholdBlueMelon is a splendid one to beholdBlueMelon is a splendid one to behold
old thread is old
__________________
http://i.imgur.com/OOJbW.jpg
Reply With Quote
  #13  
Old 09-17-2012, 03:45 PM
Tim_Rocks Tim_Rocks is offline
a true gentlemen
Tim_Rocks's Avatar
Join Date: Aug 2008
Location: USA
Posts: 1,863
Tim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to beholdTim_Rocks is a splendid one to behold
Quote:
Originally Posted by BlueMelon View Post
old thread is old
Yeah, pretty sure this script will crash your client if you try and load anything on Era. Works pretty well for adorable little servers though!


Quote:
Originally Posted by Raeiphon View Post
you should have a cap on the current amount of loaded lines - if i used this on any of era's logs it'd probably crash the client from the resulting hang
Didn't see this. I agree with the Raeiphon.
__________________
Reply With Quote
  #14  
Old 09-17-2012, 11:11 PM
scriptless scriptless is offline
Banned
Join Date: Dec 2008
Location: N-Pulse
Posts: 1,412
scriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to behold
Quick question. I see a text-box for the logname but I don't see an option for it to let you type which log's you want to load. So does this only support one log? And if not are there any preventions for abuse, such as loading files that shouldn't be loaded?

Nice work, tho styling does make it easier to read as cbk stated. Curious how you came up with the version number tho? Interesting article on that might be,
http://en.wikipedia.org/wiki/Versioning

Other then that keep up the work. Interesting to see how the final revision turns out. Also, about Code Gallery, I don't quite think it's up to code gallery quality but I'm sure you could polish it up a little so that it would make a great contribution.
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 06:31 PM.


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