New engine features

Top  Previous  Next

file_find (file handle, string to be found)

 

Finds a string in a file and places the file read pointer behind the found string.

 

var file_handle;

var index;

 

panel string_pan

{

       layer = 15;

       digits = 500, 150, 6, _a4font, 1, index;

       flags = overlay, refresh, visible;

}

 

text string_txt

{

       layer = 25;

       pos_x = 300;

       pos_y = 275;

       font = _a4font;

       flags = visible;

}

 

function find_string()

{

       file_handle = file_open_read("test.txt"); // test.txt contains "I am ready for lunch"

       index = file_find (file_handle, "ready"); // this string will be found inside test.txt (index = 10)

       //index = file_find (file_handle, "go"); // this string won't be found inside test.txt (index < 0)

       if (index > 0) // the string was found inside the test.txt file?

       {

               string_txt.string = "the text was found inside the file";

       }

       else

       {

               string_txt.string = "the text wasn't found inside the file";

       }

       file_close(file_handle);

}

 

on_f = find_string;

 

 

txt_for_dir(text, search_string)

 

This instruction reads all the file names that match the search string into separate strings of a text object.

 

text models_txt

{

       strings = 50; // display up to 50 models

}

 

starter check_models() // get the names for all the models in the current folder

{

       txt_for_dir(models_txt, "*.mdl"); // find all the files with the .mdl extension

       models_txt.visible = on; // and display their names on the screen

}

 

 

Colored stencil shadows

 

The color of the stencil shadows can be set through the mat_shadow's diffuse color vector.

 

var shadow_stencil = on;

 

starter set_shadow_color

{

       mat_shadow.diffuse_blue = 85;

       mat_shadow.diffuse_green = 85;

       mat_shadow.diffuse_red = 85;

}