save you.x in *.txt with ent_next doesen't work :(

Posted By: CocaCola

save you.x in *.txt with ent_next doesen't work :( - 03/15/18 15:59

hi,
I m working on my 3dgs games an building a level editor.
Ich have try to save all parameter of my entitys in a txt file.

it doesent work after i start the "for" command with ent_next, i cant write in file X(
Code:
///////////////////////////////
#include <acknex.h>
#include <default.c>
#include <strio.c>;
///////////////////////////////
function open_model()
{
	wait(1);
	ENTITY* TestEnt;
	char* filename = file_dialog("Replace model","*.mdl;*.hmp;*.wmb");
	if (filename)
	{
		TestEnt = ent_create (filename,camera.x,NULL);
	}
}
function main()
{
	STRING* s = "    ";
	VECTOR temp;
	while(1){
		//load a mdl
		if(key_o){
			open_model();
			while(key_o)wait(1);
		}
		// save you,x in mydile.txt
		if(key_s){
			STRING* s = "    ";
			for(you = ent_next(NULL); you!=NULL; you = ent_next(you)){
				str_for_num(s,you.x); 
			} 
			var filehandle = file_open_write ("myfile.txt");
			file_str_write(filehandle,s);
			file_close (filehandle);	
			while(key_s)wait(1);
		}
		wait(1);
	}
}

Posted By: Ayumi

Re: save you.x in *.txt with ent_next doesen't work :( - 03/15/18 17:28

You use a while... why use a for loop too?

if you want to read all Entitys, use:

Code:
you = ent_next(NULL); // retrieve first entity
while (you) // repeat until there are no more entities
{ 
   // Save,...
   you = ent_next(you); // get next entity
}

insteat of for.

Posted By: CocaCola

Re: save you.x in *.txt with ent_next doesen't work :( - 03/15/18 20:29

I see my problem is about file_dialog and then save string to *.txt.
after loading a mdl with file_dialog, the file_str_write not work.


Posted By: CocaCola

Re: save you.x in *.txt with ent_next doesen't work :( - 03/15/18 20:40

here the short example, please someone know why it does not work?
Code:
///////////////////////////////
#include <acknex.h>
#include <default.c>
#include <strio.c>;
///////////////////////////////
function main()
{
	level_load("null.wmb");
	STRING* s = "    ";
	char* filename = file_dialog("Replace model","*.mdl;*.hmp;*.wmb");
	if (filename)
	{
		ent_create (filename,nullvector,NULL);
	}
	STRING* s = "hallo welt";
	var filehandle = file_open_write ("myfile.txt");
	file_str_write(filehandle,s);
	file_close (filehandle);	
}


i get no myfile.txt in the folder
Posted By: Ayumi

Re: save you.x in *.txt with ent_next doesen't work :( - 03/15/18 21:40

It works (A7)

Other example works too!

Code:
///////////////////////////////
#include <acknex.h>
#include <default.c>
#include <strio.c>;

///////////////////////////////


///////////////////////////////
function open_model()
{
	wait(1);
	char* filename = file_dialog("Replace model","*.mdl;*.hmp;*.wmb");
	if (filename)
	{
		ent_create (filename,camera.x,NULL);
	}
}
function main()
{
	level_load(NULL);
	
	STRING* s = "    ";
	VECTOR temp;
	while(1)
	{
		if(key_o)
		{
			open_model();
			while(key_o)
				wait(1);
		}
		
		
		// save you,x in mydile.txt
		if(key_s)
		{
			STRING* s = "    ";
			
			you = ent_next(NULL); // retrieve first entity

			while (you) // repeat until there are no more entities
			{ 
			   str_for_num(s,you.x); 
			   var filehandle = file_open_write ("myfile.txt");
				file_str_write(filehandle,s);
				file_close (filehandle);
			   you = ent_next(you); // get next entity
			   wait(1);
			}

			
			
			while(key_s)wait(1);
		}
		
		wait(1);
	}
}

Posted By: CocaCola

Re: save you.x in *.txt with ent_next doesen't work :( - 03/15/18 22:42

Its not a the manual its the bug list XD
ps ich habe A8 it not work
Posted By: Ayumi

Re: save you.x in *.txt with ent_next doesen't work :( - 03/15/18 22:50

Gerade mit A8 getestet, funktioniert nicht und keine Lust mehr. Ich schau mir das morgen mal in Ruhe an.
Posted By: CocaCola

Re: save you.x in *.txt with ent_next doesen't work :( - 03/16/18 04:20

ok ich pausiere das ganze erstmal und debugge wenn mir mal was einfaällt wie man das macht , oder CMD meldungen oder. Ich warte ab was Du findes.
Posted By: txesmi

Re: save you.x in *.txt with ent_next doesen't work :( - 03/16/18 12:31

Hi,
Originally Posted By: Manual::strio.c::open_dialog::Remarks

The current directory is changed to the selected folder. If this is not desired, change it afterwards back to the game folder with the Windows API function
Code:
SetCurrentDirectory(_chr(work_dir));



Your text file should be within the folder of the model, I guess.

Salud!
Posted By: Ezzett

Re: save you.x in *.txt with ent_next doesen't work :( - 03/16/18 12:31

Vielleicht liegt es am Betriebssystem? Windows 10 sperrt aus Sicherheitsgründen ziemlich viel.
Posted By: Ayumi

Re: save you.x in *.txt with ent_next doesen't work :( - 03/16/18 12:36

@txesmi
No, i have tryed this (same Folder)
Posted By: txesmi

Re: save you.x in *.txt with ent_next doesen't work :( - 03/16/18 12:53

It is working fine for me...
Posted By: CocaCola

Re: save you.x in *.txt with ent_next doesen't work :( - 03/16/18 13:41

@Ezzett windows 10 soll angeblich das erste windows sein, für das man keine hardware treiber programmieren kann, weil die alle eine zertifikat sicherung haben, ich habe aber schon hier im forum gelesen, dass win10 und 3dgs schwierigkeiten haben frown .

I have win 8.1 and wine on linux and A8 com
Posted By: Ezzett

Re: save you.x in *.txt with ent_next doesen't work :( - 03/17/18 09:24

In welchem Ordner ist Gamestudio und dein Projekt installiert? Unter "Programme" könnte ich mir vorstellen, dass es kritisch ist, weil das Verzeichnis geschützt ist. Lässt du Gamestudio als Administrator ausführen? Ist Windows Defender deaktiviert?
Posted By: CocaCola

Re: save you.x in *.txt with ent_next doesen't work :( - 03/17/18 15:12

das wird es sei @Ezzet. Ich weiß zwar noch nicht was Windows Defender ist, aber unter linux geht es jetzt auch.
Danke laugh
Posted By: CocaCola

Re: save you.x in *.txt with ent_next doesen't work :( - 03/18/18 13:33

hatte die modelle aus einem anderem ordner geladern.
die mode wurden zwar im game angezeigt, aber mit modellen aus dem projekt ordner wird auch die text datei erstellt.
- also gehts jetzt auch auf meinem windows ordner
© 2024 lite-C Forums