How copy file texture_1.jpg to texture_2.jpg?
by Mark Brown · in Torque Game Engine · 04/02/2007 (1:55 pm) · 2 replies
Assume that you have five textures called:
outer_01.jpg, outer_02.jpg, outer_03.jpg, outer_04.jpg, outer_05.jpg.
You have several structures which call for the texture "outer.jpg".
Each time you play a new game, you want to randomly select and copy one of the five outer_0?.jpg files to overwrite a file called outer.jpg.
Any suggestion as to what code to write in an initialize.cs file to copy outer_04.jpg to outer.jpg???
outer_01.jpg, outer_02.jpg, outer_03.jpg, outer_04.jpg, outer_05.jpg.
You have several structures which call for the texture "outer.jpg".
Each time you play a new game, you want to randomly select and copy one of the five outer_0?.jpg files to overwrite a file called outer.jpg.
Any suggestion as to what code to write in an initialize.cs file to copy outer_04.jpg to outer.jpg???
About the author
#2
Many thanks for the help!
//####################
//#
//#
// ConsoleFunction(pathCopy, bool, 3, 4, "pathCopy(fromFile, toFile [, nooverwrite = true])")
//#
//#
//####################
function set_random_textures ( )
{
%ja = random_int ( 5 );
switch ( %ja )
{
case 1:
%from_file = "./data/structures/rooms/roof_floor_color_01.jpg";
case 2:
%from_file = "./data/structures/rooms/roof_floor_color_02.jpg";
case 3:
%from_file = "./data/structures/rooms/roof_floor_color_03.jpg";
case 4:
%from_file = "./data/structures/rooms/roof_floor_color_04.jpg";
case 5:
%from_file = "./data/structures/rooms/roof_floor_color_05.jpg";
}
%nooverwrite = false;
%to_file = "./data/structures/rooms/roof_floor_color_00.jpg";
pathCopy ( %from_file, %to_file, %nooverwrite );
}
04/10/2007 (8:17 am)
I found the solution I was looking for in a ConsoleFunction called "pathCopy"!Many thanks for the help!
//####################
//#
//#
// ConsoleFunction(pathCopy, bool, 3, 4, "pathCopy(fromFile, toFile [, nooverwrite = true])")
//#
//#
//####################
function set_random_textures ( )
{
%ja = random_int ( 5 );
switch ( %ja )
{
case 1:
%from_file = "./data/structures/rooms/roof_floor_color_01.jpg";
case 2:
%from_file = "./data/structures/rooms/roof_floor_color_02.jpg";
case 3:
%from_file = "./data/structures/rooms/roof_floor_color_03.jpg";
case 4:
%from_file = "./data/structures/rooms/roof_floor_color_04.jpg";
case 5:
%from_file = "./data/structures/rooms/roof_floor_color_05.jpg";
}
%nooverwrite = false;
%to_file = "./data/structures/rooms/roof_floor_color_00.jpg";
pathCopy ( %from_file, %to_file, %nooverwrite );
}
Torque Owner Tim Heldna
Example:
- Create and assign a default material (in your case probably outer_01.jpg) to your dts shape.
- Use this naming convention "base.nameOfDts" for the material name.
- For the remainder of your materials use this naming convention "outer_02.nameOfDts.jpg" etc.
function setRandomTexture(%obj) { %val = mFloor(getRandom(0, 4)); switch(%val) { case 0: %obj.setSkinName("outer_01"); case 1: %obj.setSkinName("outer_02"); case 2: %obj.setSkinName("outer_03"); case 3: %obj.setSkinName("outer_04"); case 4: %obj.setSkinName("outer_05"); } }