save entity to folder

Posted By: GameScore

save entity to folder - 05/01/12 08:05

hi,
is it possible, when a entity is loaded from a folder
to save this entity in the save_dir folder?
Posted By: sivan

Re: save entity to folder - 05/01/12 08:47

it should help:
http://www.conitec.net/beta/astr_for_entfile.htm
as I know it reads only file name, no folder path, so you can attach it to any path you need.
Posted By: GameScore

Re: save entity to folder - 05/01/12 08:55

thanks, but i know that
i dont want to save the entity filename
i want to save an entity itself
Posted By: sivan

Re: save entity to folder - 05/01/12 10:26

ahh sorry, you need file_load, add_buffer, and finally file_save
Posted By: GameScore

Re: save entity to folder - 05/01/12 10:36

ok i see,
i was try with that
but how can i grab the size of the entity?
this was needed for add_buffer
add_buffer(char* name,void* buffer,long size)
Posted By: Aku_Aku

Re: save entity to folder - 05/01/12 11:06

If you don't want to change that, you can simply copy the file:
file_cpy
Posted By: GameScore

Re: save entity to folder - 05/01/12 12:20

got it

Code:
void import_model()
{
	
	long i;
 
	char* filename = file_dialog("Import model","*.mdl;");
	if (filename)
	{
		
	void* new_ent = file_load(filename,NULL,i);
	file_save(filename,new_ent,i);
   
	wait(-1);
	editing_ent = ent_create (filename,vector(100,0,0),test_mdl);
	

	
   }
		
}



this will load and save the entity
but how can i save it at the save_dir folder?
Posted By: fogman

Re: save entity to folder - 05/01/12 16:18

I think you have to append the model filename to the save_dir string.
str_cpy save_dir to an empty string, append the model filename to it and use this string for file_save.
Posted By: GameScore

Re: save entity to folder - 05/01/12 18:01

i have no idea how i should do that
i was try but no result
Posted By: Aku_Aku

Re: save entity to folder - 05/01/12 18:07

Code:
str_cpy(your_path_string,"save_dir\\");
str_cat(your_path_string,your_model_file_name_string);


Maybe...
Posted By: GameScore

Re: save entity to folder - 05/01/12 18:30

i was try the same thing
don`t work


Code:
void load_model()
{
	
	long i;
	STRING* path_str=str_create(" ");// set the path
   
	char* filename = file_dialog("Import model","*.mdl;");
	if (filename)
	{
		
	void* new_ent = file_load(filename,NULL,i);
        add_buffer(filename,new_ent,i);
        str_cpy(path_str,"save_dir\\");
        str_cat(path_str,filename);
	file_save(path_str,new_ent,i);
       
   
    
	wait(-1);
	editing_ent = ent_create (filename,vector(100,0,0),test_mdl);
	

	
   }
		
}


Posted By: fogman

Re: save entity to folder - 05/02/12 10:03

Try this and use http://www.conitec.net/beta/aerror.htm to check if the string is right:


Code:
str_cpy(some_empty_string, save_dir);
str_cat(some_empty_string, "//"); // or "\\"
str_cat(some_empty_string, your_model_file_name_string);


Posted By: sivan

Re: save entity to folder - 05/02/12 10:07

maybe remove the space?
STRING* path_str=str_create(" ");// set the path -> STRING* path_str=str_create("");// set the path
Posted By: fogman

Re: save entity to folder - 05/02/12 11:08

Of course this won´t work:
str_cpy(path_str,"save_dir\\");

Because you copy the string "save_dir" and not the content of save_dir.
Posted By: GameScore

Re: save entity to folder - 05/02/12 19:45

now i got what i done wrong
the path was the problem

if i write it in this way

Code:
str_cpy(some_empty_string, save_dir);


it does not work, couz the save_dir contains not the full path
if i declare save_dir like this ( like the manual describes )
Code:
str_cpy(save_dir,"game_scores");


save_dir contains only game_scores but not the full path
i saw it when i write this to a textfile
Code:
file_str_write(save,save_dir);


so, everytime when i copy this entity it was copied into oblivion


now i use this solution

Code:
STRING* path_str = str_create(_chr("\\models\\"));
STRING* target_name = str_create(_chr(work_dir));
str_cat(target_name,path_str);
str_cat(target_name,filename);
file_cpy(target_name, filename);




but thanks for all your help
© 2023 lite-C Forums