Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   list of files of what's in a folder? (https://forums.graalonline.com/forums/showthread.php?t=64164)

Prozac 02-17-2006 07:02 PM

list of files of what's in a folder?
 
Is there a command that will return an array of the files that are in a folder on the server?
For example, something like:

getfilelist("levels/images/*.*");

and that returns an array

filelist={"image1.png","image2.gif","image2.mng"}

if there is a command that does something like this, what is it?
Not sure how to phrase the idea of this to put the description into a wiki search engine, so I hope someone here knows it.

ApothiX 02-17-2006 07:14 PM

Quote:

Originally Posted by Prozac
Is there a command that will return an array of the files that are in a folder on the server?
For example, something like:

getfilelist("levels/images/*.*");

and that returns an array

filelist={"image1.png","image2.gif","image2.mng"}

if there is a command that does something like this, what is it?
Not sure how to phrase the idea of this to put the description into a wiki search engine, so I hope someone here knows it.

There is a command like this, I've used it before. I just can't remember the name of it off the top of my head. If no one answers by the time I get home, I will provide you with the name of the function and the syntax.

jake13jake 02-17-2006 09:28 PM

loadfolder(str, int)
loads the content of a folder into the variable, you must specify the folder name and pattern (e.g. "levels/bodies/*.png") and if it should be recursive
http://wiki.graal.net/index.php/Crea...ient/TGraalVar

Prozac 02-17-2006 09:47 PM

thanks, but then why dosent this work?
and what are the int numbers that this function accepts
and which ints alter what paramater of the function?

//#CLIENTSIDE
function onweaponfired()
{
player.chat=loadfolder("levels/images/*.png",1);
}

the player chat is 0
regardless of the int is 0 or 1

tried setting it as a string also but that didnt work either ...
so how do i access the array of file names that this command creates? that bit of info is not on the wiki...

Ajira 02-17-2006 10:01 PM

Loadfolder annoys me.
Anyway, it is varname.loadfolder("levels/images/*.png", 1);
Then you can do player.chat = varname;
I also remember having some trouble with loadfolder with the int part. I did something like levels.loadfolder("levels/", *) and that worked. Been a while since I used it. >.>

jake13jake 02-17-2006 10:41 PM

Quote:

Originally Posted by Prozac
thanks, but then why dosent this work?
and what are the int numbers that this function accepts
and which ints alter what paramater of the function?

//#CLIENTSIDE
function onweaponfired()
{
player.chat=loadfolder("levels/images/*.png",1);
}

the player chat is 0
regardless of the int is 0 or 1

tried setting it as a string also but that didnt work either ...
so how do i access the array of file names that this command creates? that bit of info is not on the wiki...

I'd think it would be an array of strings, but perhaps it's an array of objects? I dunno.

Prozac 02-17-2006 11:09 PM

it returns an array of strings. That was the final command I needed to make this useful little image previewer. But it seems to show images from the local folder and not from the server?

Also the image Bitmap control does not even show the initial bomb.png image...

This is a free for all script that I think every graphics artist or lat looking for an image would appreciate once it works. Feel free to tweak it to have it work and look right.
PHP Code:


//#CLIENTSIDE

function onWeaponfired()
{

images.loadfolder("levels/images/*.png",0);
player.chat="found "@images.size()@" images";

 new 
GuiWindowCtrl("image_viewer")  
  {    
    
profile GuiBlueWindowProfile;
    
width 600;   
    
height 600;
    
= (screenwidth width) / 2;   
    
= (screenheight height) / 2
    
canMove true;      
    
canResize false;   
    
canMaximize false;
    
canClose true;
    
text "Image Viewer";  //text in the top left title bar of the window
    
visible true;
    

    new 
GuiScrollCtrl("image_scroll")
    {
    
profile GuiBlueScrollProfile;
    
width=150;
    
height=300;
    
x=7;
    
y=10;
    
     new 
GuiTreeViewCtrl("image_list")
     {
      
profile GuiBlueTreeViewProfile;
      
width=150;
      
height=400;
      
x=5;
      
y=10;
      
columns="0 5";
      
visible=true;  
      
      for (
i=0i<images.size(); i++)
      {
       
addnodebypath(images[i],"blah");  
      } 
     }  
//end image list  
      
    
}  //end image scroll
 
    
new GuiBitmapCtrl("image_here")
      {
      
x=20;
      
y=7;
      
width=300;
      
height=300;
      
image="bomb.png";
      }
    
   }  
//end window
  
//end weaponfired


function image_list.onSelect()
{
  
player.chat=image_list.getselectednode();  //for variable testing
  
image_here.image=image_list.getselectednode();


so .. if u can make the image show up in the window then please post an update of this here. this should work but it dosent quite show the pics.

Rick 02-18-2006 01:15 AM

It's a clientside script, what do you expect?

Prozac 02-18-2006 02:41 AM

problem: variables set serverside cannot be read clientside even if its within the same block of npc code. Nor can triggeractions be sent server side.

solution: set a serverr.string to the value you want to read clientside
and when the client reads the data, clear out the serverr.string.

is there a more efficient way to do that?

and more importantly, why dosent the image show up in the GuiBitmapCtrl?

Riot 02-18-2006 03:56 AM

Quote:

Originally Posted by Prozac
problem: variables set serverside cannot be read clientside even if its within the same block of npc code. Nor can triggeractions be sent server side.

Why wouldn't a triggeraction work? I have done something similar using triggerServer/Client...

ApothiX 02-18-2006 09:30 AM

Quote:

Originally Posted by Prozac
problem: variables set serverside cannot be read clientside even if its within the same block of npc code. Nor can triggeractions be sent server side.

solution: set a serverr.string to the value you want to read clientside
and when the client reads the data, clear out the serverr.string.

is there a more efficient way to do that?

and more importantly, why dosent the image show up in the GuiBitmapCtrl?

er.. you're using a WNPC, why would you set a serverr. string to read the variable clientside? just use triggeraction(0, 0, "clientside", "WEAPONNAME", temp.whatevervariable);

But yea, loadfolder is a serverside function.


All times are GMT +2. The time now is 04:30 PM.

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