Load from a directory?
by Kirk Sigmon · in Torque Game Builder · 10/30/2005 (4:32 pm) · 2 replies
I've been trying to implement a Datablock system for my game that scans all image files in a folder and converts them to datablocks for use. I know this is simplistic and problematic, just bear with me.
Anyway, I've come up with the following code. It seems sound to me, but torque keeps coming back with the (included) error message. Is there something wrong with this code, or is it just a generic torque thing?
Anyway, I've come up with the following code. It seems sound to me, but torque keeps coming back with the (included) error message. Is there something wrong with this code, or is it just a generic torque thing?
function BodyLoad()
{
%FileSpec = "~/client/data/body_*.png";
%Target = FindFirstFile(%FileSpec);
%begstring = "~/client/data/body/";
while (strlen(%Target) > 0){
datablock fxImageMapDatablock2D(%Target){
mode = cell;
cellWidth = 32;
cellHeight = 48;
textureName = %begstring %Target;
};
%Target = FindNextFile(%FileSpec);
}
}Quote:T2D/client/loadall.cs Line: 8 - Syntax error.
>>> Advanced script error report. Line 15.
>>> Some error context, with ## on sides of error halt:
while (strlen(%Target) > 0){
^datablock fxImageMapDatablock2D(%Target)##{##
^^ mode = cell;
^^ cellWidth = 32;
^^ cellHeight = 48;
>>> Error report complete.
About the author
Torque Owner Ricky Taylor
Try
OR
eval("datablock fxImageMapDatablock2D(" @ %Target @ ") { mode = cell; cellWidth = 32; cellHeight = 48; textureName = %begstring %Target; };");Tell me if you have any luck, second one is most likely to work. =)