|
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
OP
Senior Member
|
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(
///////////////////////////////
#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
User
|
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:
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
OP
Senior Member
|
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
OP
Senior Member
|
OP
Senior Member
Joined: Mar 2014
Posts: 359
|
here the short example, please someone know why it does not work?
///////////////////////////////
#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
User
|
User
Joined: Oct 2008
Posts: 681
Germany
|
It works (A7) Other example works too!
///////////////////////////////
#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
OP
Senior Member
|
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]
#471720
03/16/18 12:31
03/16/18 12:31
|
Joined: Jun 2007
Posts: 1,337 Hiporope and its pain
txesmi
Serious User
|
Serious User
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
|
Hi, 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
SetCurrentDirectory(_chr(work_dir));
Your text file should be within the folder of the model, I guess. Salud!
|
|
|
|