Pref to file count.
by Bob Mann · in Torque 3D Beginner · 12/14/2010 (3:21 am) · 17 replies
Hey I am trying to make a way to set a pref depending on the number of files in a folder.
Is this possible?
for(%f = 1; isFile("./server/database/players/" @ %f @ ".txt"); %f++)
For what I am aware of this will only work with the files numbered. Is there another way?
Is this possible?
for(%f = 1; isFile("./server/database/players/" @ %f @ ".txt"); %f++)
For what I am aware of this will only work with the files numbered. Is there another way?
#2
Edit:
I keep getting a parse error with this:
12/14/2010 (1:32 pm)
Thanks.Edit:
I keep getting a parse error with this:
if(!isFile("~/server/database/players/" @ %this.username @ ".xml")
{
}
#4
12/17/2010 (2:06 am)
No. Its a Script Object, or part of one.>>> Some error context, with ## on sides of error halt:
echo("SAVE : CURRENTPLAYERCOUNT : " @ $save::playercount @ " !");
//=========================================================
//^2. Functions
//=========================================================
function save::adddata(%this)
{
^if(!isFile("~/server/database/players/" @ %this.username @ ".xml")
^{
##^##
^}
}
>>> Error report complete.
#5
12/17/2010 (2:27 am)
Count/match your number of parenthesis in the if statement.
#6
12/17/2010 (2:34 am)
Whole function, so far.function save::adddata(%this)
{
if(!isFile("~/server/database/players/" @ %this.username @ ".xml")
{
//nothing
}
}
#7
12/17/2010 (4:59 am)
Michael's right, you need another ")" at the end of the if-statement.
#8
Thanks.
Edit:
Could some one help me debug this?
Edit 2: New code posted.
12/17/2010 (1:41 pm)
I did not notice that.Thanks.
Edit:
Could some one help me debug this?
Edit 2: New code posted.
#9
Also, is your directory setup correct? If this file is in scripts/server then it's searching for the save file scripts/server/server/database/players/Pitfall.save
12/31/2010 (8:11 pm)
Well for one you spelled "given" wrong. :PAlso, is your directory setup correct? If this file is in scripts/server then it's searching for the save file scripts/server/server/database/players/Pitfall.save
#10
12/31/2010 (10:06 pm)
The directory is fine. It just can't read the variables from the file.
#11
01/02/2011 (12:52 am)
I've never used getField before. That separates by TAB right? Try putting each field on a different line or use getWord with only one space in between each.
#12
01/02/2011 (8:33 pm)
Tried putting them on new lines.1 Pitfall testpass lol@fail.net //end varsBut it still dose not work.
#13
'Cause I think I found your problem.
It looks like
01/02/2011 (9:55 pm)
Is your long echo line being displayed in the console?'Cause I think I found your problem.
It looks like
if(!isFile("./server/database/players/" @ %urname @ ".save")) should be if(isFile("./server/database/players/" @ %urname @ ".save"))
#14
I removed the ! but it always comes back as "player dose not exist".
More edit:
Rewritten from scratch, Seems to work fine now.
01/02/2011 (10:40 pm)
Yes it dose but username echoed as nothing. I removed the ! but it always comes back as "player dose not exist".
More edit:
Rewritten from scratch, Seems to work fine now.
#15
01/04/2011 (12:33 am)
The "!" isn't supposed to be there. Maybe it's not working because the directory isn't right. Try using expandFilename.
#16
01/04/2011 (3:48 am)
The directory is right.//From account creation
%file = new FileObject();
%file.openforwrite("./server/database/players/" @ %urname @ ".save");
#17
01/05/2011 (6:02 am)
Well the "!" isn't supposed to be there. It should beif (isFile(%file))
{
// Do stuff with file
}
Associate Rene Damm
getFileCount() is probably what you're looking for.