Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   requestText("folders", ""); (https://forums.graalonline.com/forums/showthread.php?t=67424)

ForgottenLegacy 07-18-2006 12:10 PM

requestText("folders", "");
 
Simple topic name. Now that I have your attention, I'll state my problem: WTFORK x_x!!

Okay. My rights are set to this:
NPC Code:

rw */*
rw */*/*
rw */*/*/*
rw */*/*/*/*
rw */*/*/*/*/*
rw */*/*/*/*/*/*
rw */*/*/*/*/*/*/*
rw */*/*/*/*/*/*/*/*
rw */*/*/*/*/*/*/*/*/*
rw */*/*/*/*/*/*/*/*/*/*



Now I am trying to make a client FTP to add to my TGConsole. When I do a requestText(), passing "folders" as the first param, it works! ...sort of! Instead of a list of all of the folders in the FTP, I get this:
NPC Code:

*/
*/*/
*/*/*/
*/*/*/*/
*/*/*/*/*/
*/*/*/*/*/*/
*/*/*/*/*/*/*/
*/*/*/*/*/*/*/*/
*/*/*/*/*/*/*/*/*/
*/*/*/*/*/*/*/*/*/*/



In all honesty, that return is useless. Useless for making an FTP. Can someone fix this please, or help me through this problem? I do not want to change my rights, because I'm pretty much in charge of the FTP, and I create and delete folders left and right. I don't want to update my rights every time I create or delete a folder.

-- Kaidenn A. Neseta

Omini 07-18-2006 03:45 PM

All I know about a Client RC is that you need a weapon, reading folder names and what not I don't know.

PHP Code:

//#CLIENTSIDE

public function openFileBrowser() {
  
requesttext("folders","") ;
  new 
GuiWindowCtrl(FileBrowser_Screen) {
    
profile "GuiWindowProfile";
    
5050;
    
width 500height 450;
    
canMove true;
    
canResize true;
    
canClose true;
    
text "File Browser";
    
tile true;
    
destroyonhide true;

    new 
GuiScrollCtrl(FileBrowser_TreeScroll) {
      
profile "GuiScrollProfile";
      
horizSizing "right";
      
vertSizing "height";
      
5;
      
y  23;
      
width 136;
      
height 335;
      
hScrollBar "dynamic";
      
vScrollBar "dynamic";
      
tile true;

      new 
GuiTreeViewCtrl(FileBrowser_Tree) {
        
profile "GuiTreeViewProfile";
        
horizSizing "width";
        
0;
        
width 120;
        
fitParentWidth false;
        
sortmode "name";
        
thiso.catchevent(name,"onSelect","onTreeView");
      }
    }
    new 
GuiTextCtrl(FileBrowser_NameLabel) {
      
profile "GuiDarkTextProfile";
      
position "170 24";
      
extent "60 22";
      
minExtent "8 22";
      
text "Name";
    }
    new 
GuiTextCtrl(FileBrowser_RightsLabel) {
      
profile "GuiDarkTextProfile";
      
position "285 24";
      
extent "40 22";
      
minExtent "8 22";
      
text "Rights";
    }
    new 
GuiTextCtrl(FileBrowser_SizeLabel) {
      
profile "GuiDarkTextProfile";
      
position "325 24";
      
extent "50 22";
      
minExtent "8 22";
      
text "Size";
    }
    new 
GuiTextCtrl(FileBrowser_ModifiedLabel) {
      
profile "GuiDarkTextProfile";
      
position "375 24";
      
extent "60 22";
      
minExtent "8 22";
      
text "Modified";
    }

    new 
GuiScrollCtrl(FileBrowser_FilesScroll) {
      
profile "GuiScrollProfile";
      
horizSizing "width";
      
vertSizing "height";
      
144;
      
y  44;
      
width 351;
      
height 311;
      
hScrollBar "alwaysOff";
      
vScrollBar "dynamic";
      
tile true;

      new 
GuiTextListCtrl(FileBrowser_FilesList) {
        
profile "GuiTextListProfile";
        
horizSizing "width";
        
vertSizing "height";
        
0;
        
width 330;
        
fitParentWidth true;
        
sortMode "name";
        
clipColumnText true;
        
lineSpacing 20;
        
fontSize 18;
        
setIconSize(16,18);
        
columns = {0,120,160,230};
      }
    }
    new 
GuiScrollCtrl(FileBrowser_Scroll) {
      
profile "GuiScrollProfile";
      
5;
      
360;
      
width 490;
      
height 85;
      
horizSizing "width";
      
vertSizing "top";
      
hScrollBar "alwaysOff";
      
vScrollBar "dynamic";

      new 
GuiMLTextCtrl(FileBrowser_DebugText) {
        
profile "GuiMLTextProfile";
        
horizSizing "width";
        
0;
        
width 470;
      }
    }
  }
  new 
GuiContextMenuCtrl(FileBrowser_Menu) {
    
profile "GuiPopUpMenuProfile";
    
textprofile "GuiTextListProfile";
    
width 20;
//    setIconSize(16,16);

    
clearRows();
    
addRow(0,"Download");
    
addRow(1,"Edit As Text");
    
addRow(2,"Upload File(s)");
    
addRow(-1,"-");
    
addRow(3,"Reload");
    
addRow(4,"Move");
    
addRow(5,"Rename");
    
addRow(-1,"-");
    
addRow(6,"Delete");
  }

  
FileBrowser_DebugText.addText("Welcome to the filebrowser!"true);
  
FileBrowser_Screen.bringToFront();
}

function 
FileBrowser_FilesList.onResize(newwidthnewheight) {
  if (
newwidth<320newwidth 320;
  
FileBrowser_FilesList.columns = {0,newwidth-210,newwidth-170,newwidth-100};
  
widthdiff newwidth-330;
  
FileBrowser_RightsLabel.285+widthdiff;
  
FileBrowser_SizeLabel.325+widthdiff;
  
FileBrowser_ModifiedLabel.395+widthdiff;
}

function 
FileBrowser_FilesList.onRightMouseDown(modifier,mx,my,mcount) {
  
this.fileid FileBrowser_FilesList.getRowIdAtPoint(mx,my);
  if (
this.fileid>=0) {
    
FileBrowser_FilesList.setSelectedById(this.fileid);
    
this.selectedfile FileBrowser_FilesList.getSelectedText();
    
this.selectedfile.pos("\t");
    if (
i>=0)
      
this.selectedfile this.selectedfile.substring(0,i);
    
FileBrowser_Menu.open(mx,my);
  }
}

function 
FileBrowser_Menu.onSelect(entryid,text) {
  switch (
text) {
    case 
"Download": {
        
selectFileForDownload(this.selectedfile);
        break;
      }
    case 
"Edit As Text": {
        break;
      }
    case 
"Upload File(s)": {
        
selectFileForUpload();
        break;
      }
    case 
"Reload": {
        
triggerserver("gui","Editor","updatefile",this.selectedfile);
        break;
      }
    case 
"Move": {
        
TextEditor.openTextInput("MoveFiles","Move Files","Enter the target folder:","Move");
        if (
MoveFiles_Field.text=="")
          
MoveFiles_Field.text this.showfolder;
        if (!
MoveFiles_Field.text.ends("/"))
          
MoveFiles_Field.text @= "/";
        break;
      }
    case 
"Rename": {
        
TextEditor.openTextInput("RenameFile","Rename File","Enter the new filename:","Rename");
        
RenameFile_Field.text this.selectedfile;
        break;
      }
    case 
"Delete": {
        
requestFileDeletion(this.selectedfile);
        
requesttext("folder",this.showfolder);
        break;
      }
  }
}

function 
MoveFiles_Button.onAction() {
  
targetfolder MoveFiles_Field.text;
  if (!
targetfolder.ends("/"))
    
targetfolder @= "/";
  echo(
"moving files to : " targetfolder);
  
requestFilesMove(targetfolder,this.selectedfile);
  
requesttext("folder",this.showfolder);
  
MoveFiles_Window.hide();
}

function 
RenameFile_Button.onAction() {
  
newfilename RenameFile_Field.text;
  echo(
"renaming file to: " newfilename);
  
requestFileRename(this.selectedfile,newfilename);
  
requesttext("folder",this.showfolder);
  
RenameFile_Window.hide();
}

function 
onFolderLog(text) {
  echo(
"folderlog: " text);
  
FileBrowser_DebugText.addText("\n" texttrue);
  
FileBrowser_DebugText.scrollToBottom();
}

function 
onReceiveText(texttype,textoption,textlines) { 
  switch (
texttype) {
    case 
"folders":
      
FileBrowser_Tree.clearNodes();
      for (
foldernametextlines) {
        
subnode FileBrowser_Tree.addNodeByPath(foldername,"/");
        
subnode.sortgroup 1;
        
subnode.expanded false;
      }
      
FileBrowser_Tree.sort();
      break;
    case 
"folder":
      
FileBrowser_FilesList.clearRows();
      
this.displayedfiles textlines;
      for (
i=0i<textlines.size(); i++) {
        
fileentry textlines[i];

        
// Add the file entry
        
str fileentry[0] @ '\t' fileentry[1] @ '\t' fileentry[2] @ '\t' fileentry[3];
        
FileBrowser_FilesList.addRow(i,str);

        
// Set icon
        
dotpos fileentry[0].positions(".");
        
imgfilename dotpos.size() > "fileicon_" fileentry[0].substring(dotpos[dotpos.size()-1] + 1, -1) @ ".png" "";
        
lastRow().icon.drawimagerectangle(0,0,imgfilename,0,0,16,16);
      }
      
FileBrowser_FilesList.sort();
      break;
  }
}

function 
onTreeView(obj,node,path,dot) {
  
this.showfolder path;
  
requesttext("folder",path);
}

function 
lastRow() return FileBrowser_FilesList.rows[FileBrowser_FilesList.rows.size()-1]; 

I have that in a weapon called -FileBrowser

ForgottenLegacy 07-18-2006 11:31 PM

That does nothing for me. I still get the very same output. The problem is, requestText("folders", ""); reads my rights, and NOT the folder tree. This is a bug that needs to be fixed.

Yen 07-19-2006 07:49 PM

requesttext("folder",path) is what you want.
Notice the 'folder' instead of 'folders'

ForgottenLegacy 07-19-2006 10:09 PM

Yen, that only gives me the contents of a single folder, files and everything. I want to get the entire folder tree.

Yen 07-20-2006 08:39 PM

Quote:

Originally Posted by ForgottenLegacy
Yen, that only gives me the contents of a single folder, files and everything. I want to get the entire folder tree.

O-o
That's not possible, so make a function.
There's no problem with 'folders,' it's mean't to return your folder rights, not a folder tree.

ApothiX 07-21-2006 03:29 AM

That is a (known?) bug with the Client-RC. You have to specifically set the folders you want access to in your rights, instead of using wildcards (wildcards for the filename do work, just not for the folder, ie: rw temp/blah/* will work, temp/*/* will not.)


All times are GMT +2. The time now is 05:35 AM.

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