Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-02-2010, 02:17 AM
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
Downloader

Well I made this since I hated the whole opening my browser and what not to download the new beta client (If I could find the name of the Beta TextCtrl, I'd do it automatically but w/e).

Basically downloads what you have set in this.dlurl.

PHP Code:
//#CLIENTSIDE

function onCreated() {
  
// You'll have to fix this line.. well the start of it.
  
this.dlurl "http://www.path.to/the/right/place/" getplatform() @ ".zip";
}

function 
ChatBar.onAction() {
  if (
ChatBar.text == "/download") {
    
ChatBar.text "";
    
createGUI();
    
// Comment the line below if you want the 
    // joy of clicking a button.
    
downloadFile(); 
  }
}

function 
createGUI() {
  new 
GuiWindowCtrl("BetaDownloader") {
    
profile GuiBlueWindowProfile;
    
width 200;
    
height 72;
    
= (screenwidth width) / 2;
    
= (screenheight height) / 2;
    
text "Beta Downloader";
    new 
GuiButtonCtrl("BetaDownloader_Download") {
      
profile GuiBlueButtonProfile;
      
10;
      
30;
      
active true;
      
width 180;
      
text "Download" SPC extractfilename(thiso.dlurl);
      
thiso.catchevent(this.name"onAction""downloadFile");
    }
  }
}

function 
downloadFile() {
  
with (BetaDownloader_Download) {
    
active false;
    
text "Downloading...";
  }
  
temp.req requesturl(this.dlurl);
  
thiso.catchevent(temp.req"onReceiveData""downloadedFile");
}

function 
downloadedFile(obj) {
  
temp.file extractfilename(obj.file);
  
BetaDownloader_Download.text file SPC "downloaded.";
  
obj.fulldata.savestring(file0);

Portable download functions:

PHP Code:
//#CLIENTSIDE
function downloadFile(dlurl) {
  
temp.req requesturl(dlurl);
  
thiso.catchevent(temp.req"onReceiveData""downloadedFile");
}

function 
downloadedFile(obj) {
  
temp.filename extractfilename(obj.file);
  
obj.fulldata.savestring(temp.filename0);

__________________
Quote:
Reply With Quote
  #2  
Old 09-02-2010, 02:22 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
nice
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #3  
Old 09-02-2010, 02:33 AM
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
@Skyld: Integrate such functionality please.
__________________
Quote:
Reply With Quote
  #4  
Old 09-02-2010, 02:47 AM
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
PHP Code:
thiso.catchevent(this.name"onAction""downloadFile"); 
this would trigger the event onDownloadFile, no?
__________________
Reply With Quote
  #5  
Old 09-02-2010, 03:05 AM
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 cbk1994 View Post
PHP Code:
thiso.catchevent(this.name"onAction""downloadFile"); 
this would trigger the event onDownloadFile, no?
Nope, at least not in V6.
__________________
Quote:
Reply With Quote
  #6  
Old 09-02-2010, 05:31 AM
LoneAngelIbesu LoneAngelIbesu is offline
master of infinite loops
LoneAngelIbesu's Avatar
Join Date: May 2007
Location: Toldeo, Ohio
Posts: 1,049
LoneAngelIbesu has a spectacular aura aboutLoneAngelIbesu has a spectacular aura about
Send a message via AIM to LoneAngelIbesu
Quote:
Originally Posted by fowlplay4 View Post
Nope, at least not in V6.
Not in v5, either.
__________________
"We are all in the gutter, but some of us are looking at the stars."
— Oscar Wilde, Lady Windermere's Fan
Reply With Quote
  #7  
Old 09-02-2010, 05:52 AM
MrOmega MrOmega is offline
One More Time
MrOmega's Avatar
Join Date: Aug 2010
Location: TN, USA
Posts: 631
MrOmega is an unknown quantity at this point
Send a message via AIM to MrOmega Send a message via MSN to MrOmega Send a message via Yahoo to MrOmega
Quote:
Originally Posted by fowlplay4 View Post
Nope, at least not in V6.
Couldnt you just trigger it with trigger() / scheduleEvent()?

PHP Code:
thiso.trigger"DownloadFile"NULL);
thiso.scheduleEvent0"DownloadFile"NULL); 
__________________
Time is the fire in which we burn...
Up, Up, Down, Down, Left, Right, Left, Right, B, A, Select, Start! Now I got 99 LIVES!!!
Reply With Quote
  #8  
Old 09-02-2010, 05:54 AM
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
Good to know, I always thought the "on" was optional (as it is in other functions, such as trigger) but it would be prefixed with "on" automatically if you left it out.
__________________
Reply With Quote
  #9  
Old 09-02-2010, 07:27 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Quote:
Originally Posted by cbk1994 View Post
PHP Code:
thiso.catchevent(this.name"onAction""downloadFile"); 
this would trigger the event onDownloadFile, no?
Could be possible that in order for the "on" to be optional you have to capitalize the D, like
PHP Code:
thiso.catchevent(this.name"onAction""DownloadFile"); 
But I could be wrong. In CatchEvents, I've always included the on.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 01:36 PM.


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