can anyone tell me why this function crashes? I'm sure its something to with the line "if (temp_vec[0]==255)" ..in old c-script you used to be able to assign the pixel to temp and read it like temp.red ..this doesnt work in lite C apparently.
Code:
var treemask_array[256][256];
BMAP* treemask = "treemask.tga";
function init_treemask()
{
var format;
var pixel;
var county=0;
var countx=256;
var temp_vec[3];
format=bmap_lock(treemask,0);
while(countx>0)
{
while(county<256)
{
pixel = pixel_for_bmap(treemask,countx,county);
pixel_to_vec(temp_vec,NULL,888,pixel);
//only write to array if red is 255
if (temp_vec[0]==255)
{
treemask_array[countx][county]=255;
}
else {treemask_array[countx][county]=0;}
county+=1;
}
if (county>=256)
{
county=0;
}
countx-=1;
}
bmap_unlock(treemask);
}
From the manual: pixel_to_vec(COLOR* color,var alpha,var format,var pixel);
You have to use a Vector or Color at the first parameter not a array. This should solved your problem. EDIT : I dont see your secound post ... I need glasses! argh!