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 02-17-2006, 07:02 PM
Prozac Prozac is offline
one of the good guys
Prozac's Avatar
Join Date: Jan 2006
Posts: 245
Prozac is on a distinguished road
Send a message via AIM to Prozac
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.
Reply With Quote
  #2  
Old 02-17-2006, 07:14 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
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.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #3  
Old 02-17-2006, 09:28 PM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
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
Reply With Quote
  #4  
Old 02-17-2006, 09:47 PM
Prozac Prozac is offline
one of the good guys
Prozac's Avatar
Join Date: Jan 2006
Posts: 245
Prozac is on a distinguished road
Send a message via AIM to 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...
Reply With Quote
  #5  
Old 02-17-2006, 10:01 PM
Ajira Ajira is offline
Poont.
Join Date: Oct 2004
Location: NY, USA
Posts: 477
Ajira is on a distinguished road
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. >.>
__________________
Liek omigosh.

Reply With Quote
  #6  
Old 02-17-2006, 10:41 PM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
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.
Reply With Quote
  #7  
Old 02-17-2006, 11:09 PM
Prozac Prozac is offline
one of the good guys
Prozac's Avatar
Join Date: Jan 2006
Posts: 245
Prozac is on a distinguished road
Send a message via AIM to Prozac
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.
Reply With Quote
  #8  
Old 02-18-2006, 01:15 AM
Rick Rick is offline
PipBoy Extraordinaire!
Rick's Avatar
Join Date: Jul 2004
Location: Long Beach, California.
Posts: 831
Rick is on a distinguished road
It's a clientside script, what do you expect?
Reply With Quote
  #9  
Old 02-18-2006, 02:41 AM
Prozac Prozac is offline
one of the good guys
Prozac's Avatar
Join Date: Jan 2006
Posts: 245
Prozac is on a distinguished road
Send a message via AIM to 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?

Last edited by Prozac; 02-18-2006 at 03:02 AM..
Reply With Quote
  #10  
Old 02-18-2006, 03:56 AM
Riot Riot is offline
Delteria Management
Join Date: Nov 2003
Location: Seminole County, Florida
Posts: 280
Riot is on a distinguished road
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...
Reply With Quote
  #11  
Old 02-18-2006, 09:30 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
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.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
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 12:10 AM.


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