Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (SBGuy), 712 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
save you.x in *.txt with ent_next doesen't work :( #471696
03/15/18 15:59
03/15/18 15:59
Joined: Mar 2014
Posts: 359
CocaCola Offline OP
Senior Member
CocaCola  Offline OP
Senior Member

Joined: Mar 2014
Posts: 359
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);
	}
}


Re: save you.x in *.txt with ent_next doesen't work :( [Re: CocaCola] #471698
03/15/18 17:28
03/15/18 17:28
Joined: Oct 2008
Posts: 681
Germany
Ayumi Offline
User
Ayumi  Offline
User

Joined: Oct 2008
Posts: 681
Germany
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.


Last edited by Ayumi; 03/15/18 17:32.
Re: save you.x in *.txt with ent_next doesen't work :( [Re: Ayumi] #471706
03/15/18 20:29
03/15/18 20:29
Joined: Mar 2014
Posts: 359
CocaCola Offline OP
Senior Member
CocaCola  Offline OP
Senior Member

Joined: Mar 2014
Posts: 359
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.



Last edited by CocaCola; 03/15/18 20:31.
Re: save you.x in *.txt with ent_next doesen't work :( [Re: CocaCola] #471708
03/15/18 20:40
03/15/18 20:40
Joined: Mar 2014
Posts: 359
CocaCola Offline OP
Senior Member
CocaCola  Offline OP
Senior Member

Joined: Mar 2014
Posts: 359
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

Last edited by CocaCola; 03/15/18 20:41.
Re: save you.x in *.txt with ent_next doesen't work :( [Re: CocaCola] #471711
03/15/18 21:40
03/15/18 21:40
Joined: Oct 2008
Posts: 681
Germany
Ayumi Offline
User
Ayumi  Offline
User

Joined: Oct 2008
Posts: 681
Germany
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);
	}
}


Last edited by Ayumi; 03/15/18 22:10.
Re: save you.x in *.txt with ent_next doesen't work :( [Re: Ayumi] #471713
03/15/18 22:42
03/15/18 22:42
Joined: Mar 2014
Posts: 359
CocaCola Offline OP
Senior Member
CocaCola  Offline OP
Senior Member

Joined: Mar 2014
Posts: 359
Its not a the manual its the bug list XD
ps ich habe A8 it not work

Last edited by CocaCola; 03/15/18 22:43.
Re: save you.x in *.txt with ent_next doesen't work :( [Re: CocaCola] #471714
03/15/18 22:50
03/15/18 22:50
Joined: Oct 2008
Posts: 681
Germany
Ayumi Offline
User
Ayumi  Offline
User

Joined: Oct 2008
Posts: 681
Germany
Gerade mit A8 getestet, funktioniert nicht und keine Lust mehr. Ich schau mir das morgen mal in Ruhe an.

Re: save you.x in *.txt with ent_next doesen't work :( [Re: Ayumi] #471716
03/16/18 04:20
03/16/18 04:20
Joined: Mar 2014
Posts: 359
CocaCola Offline OP
Senior Member
CocaCola  Offline OP
Senior Member

Joined: Mar 2014
Posts: 359
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.

Re: save you.x in *.txt with ent_next doesen't work :( [Re: CocaCola] #471720
03/16/18 12:31
03/16/18 12:31
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
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!

Re: save you.x in *.txt with ent_next doesen't work :( [Re: CocaCola] #471721
03/16/18 12:31
03/16/18 12:31
Joined: Aug 2003
Posts: 118
Deutschland
E
Ezzett Offline
Member
Ezzett  Offline
Member
E

Joined: Aug 2003
Posts: 118
Deutschland
Vielleicht liegt es am Betriebssystem? Windows 10 sperrt aus Sicherheitsgründen ziemlich viel.

Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1