Problem with line break

Posted By: PadMalcom

Problem with line break - 06/06/12 15:17

Hi, I have to following code:

Code:
ent_create("graphics\\npc\\EarpYellow.tga", nullvector, actEarp);



The compiler tells me the image could not be found because it recognizes a line break at "\n" behind graphics. How can I avoid that?
Posted By: GameScore

Re: Problem with line break - 06/06/12 15:38

try something like this

Code:
STRING*file_name = str_create("graphics\\npc\\EarpYellow.tga");
ent_create(file_name, nullvector, actEarp);


Posted By: PadMalcom

Re: Problem with line break - 06/07/12 15:47

Hey GameScore,
that does not work, same result.
Posted By: fogman

Re: Problem with line break - 06/07/12 15:56

You could write the string into a textfile and read it out with txt_load.
Then "\n" characters will not be converted to line feeds.

Edit:

TEXT* txt = { strings = 1; flags = SHOW; }

...

txt_load(txt,"paths.txt");
ent_create((txt.pstring)[0], nullvector, actEarp);

Posted By: GameScore

Re: Problem with line break - 06/07/12 16:15

or you go the easy way and rename the folder npc
Posted By: EvilSOB

Re: Problem with line break - 06/07/12 16:35

It doesnt appear to be the '\n' causing the issue, it just looks like it
because the '\n' gets procss by the error message...

Putting in ANY sort of path into the ent-create seems to generate the error.
its like ent_create cant handle any paths in the string...
Posted By: Lukas

Re: Problem with line break - 06/07/12 16:53

You can just use "/" instead of "\".
Posted By: EvilSOB

Re: Problem with line break - 06/07/12 17:02

That dont work (for me) either... Where did that idea come from Lukas?

I had to got this far to get it to go...
Code:
ENTITY* ent_create2(STRING* filename, VECTOR* pos, VOID* actionn)
{
	int size;	void* pFile = file_load(filename, NULL, &size);
	STRING* shortname=str_create(_chr(filename));
	while(str_stri(shortname,"\\"))	str_clip(shortname, str_stri(shortname,"\\"));
	add_buffer(shortname, pFile, size);		
	ENTITY* ent = ent_create(shortname, pos, actionn);		
	add_buffer(shortname, NULL, 0);		file_load(NULL, pFile, 0);
	str_remove(shortname);			return(ent);
}


And I have no idea whats going to happen if you try to load files from
different folders that have the same name....

I suspect the first one to be opened will keep on being reused...
Posted By: PadMalcom

Re: Problem with line break - 06/07/12 17:14

Weired thing is that the entity is actually loaded correctly but acklog.txt prints out this error message.

If there is no elegant solution I'd really rename that folder.
Posted By: EvilSOB

Re: Problem with line break - 06/07/12 18:40

Try renaming the folder as a test....

Then I would think about logging a bug report...
Posted By: Lukas

Re: Problem with line break - 06/07/12 18:57

Originally Posted By: EvilSOB
That dont work (for me) either... Where did that idea come from Lukas?

Well, on some website I once read that because most operating systems use "/" instead of "\", Windows supports "/", too. You can try it, by e.g. acessing "C:/Windows" in the Windows explorer, it will just correct it to the "\" notation.
The website recommended always using "/", because that way it's easier to port code from Windows to other operating systems. Even though Gamestudio only works on Windows, I like to use it there, too, because it seems much cleaner than having to use "\\".

I tried using ent_create with a subfolder and "/" and it worked for me.

Maybe you could just use PRAGMA_PATH or a WDL with a path statement?
© 2024 lite-C Forums