Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, degenerate_762), 907 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Possible data change after file_str_read? #306284
01/20/10 23:15
01/20/10 23:15
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline OP
Expert
Helghast  Offline OP
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
Hello,

I'm trying to get data out of a text file to read out player movement keys.
I'm using the following code (relevant piece) to do so:

Code:
var fhandle_n = file_open_read("keyMapping.ini"); // open file
	STRING* tempStr = str_create("");
	STRING* getCurrentKey = str_create("");
	
	// get player number from file
	str_cpy(tempStr, "player");
	str_cat(tempStr, str_for_int(NULL, playerStoreNumber+1));
	error(tempStr);
	file_str_read(fhandle_n, tempStr);
	error(tempStr);

	file_close(fhandle_n); // close file



now, playerStoreNumber is a global variable, that gets increased upon every player that is placed in the level.
Currently, I have 2 player models, and thus, this piece of code gets executed twice.
I've put in error's to see what my string outputs.
So the first time it says: player1, then the second one again after the file_str_read says player1 as well...
Nothing wrong yet, but when i run this function again (to initialise the key setup for the 2nd player; the first time i get player2, but right after the file_str_read, it displays player1 again...

I cant see why this should be a bug for me; since i only do a engine function call... Hope this info is usefull, but to be certain im not doing anything wrong, here's how my keyMapping.ini file looks like:

Code:
player1,w,a,s,d,q,e,c,r
player2,i,j,k,l,u,o,m,y



like I said, both times, I get the data from player1 only, even though the string appended does state player2 the second time, but get's reset after a file_str_read call.

regards,


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: Possible data change after file_str_read? [Re: Helghast] #306335
01/21/10 09:25
01/21/10 09:25
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
I do not understand your problem. As far as I see, you open a file and read its first word up to the comma, which is "player1". What problem do you have with that?

Re: Possible data change after file_str_read? [Re: jcl] #306336
01/21/10 09:46
01/21/10 09:46
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline OP
Expert
Helghast  Offline OP
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
it was late last night, the problem I had, i first want to read player1 controls. then player2 controls.
But on the second call of this function, the "player2" string is created, but somehow reverted back to "player1" after the file_str_read call.
hope this is a bit more clear.

regards,


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: Possible data change after file_str_read? [Re: Helghast] #306337
01/21/10 09:47
01/21/10 09:47
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Why do you think the read string would be different the second time?

Re: Possible data change after file_str_read? [Re: jcl] #306339
01/21/10 10:01
01/21/10 10:01
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline OP
Expert
Helghast  Offline OP
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
because that's what it outputs... look at my script, when this script is running the 2nd time i call it, the first error outputs "player2", which at that point in time, is fine to me... however, after the file_str_read, i do another error (after isolating it to that point), and it output "player1" to me... means that after the engine function call, the string got edited or reverted somehow.

That's why i flagged it as a possible bug.

regards,


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: Possible data change after file_str_read? [Re: Helghast] #306341
01/21/10 10:38
01/21/10 10:38
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Hmm, I think we're going in circles.

When a file begins with "player1" and you run your code above, I expect that the string contains "player1" afterwards regardless how often you try. Your player variable is irrelevant because you overwrite the string from the file.

Maybe I'm stupid, but I still have no clue what your problem is.

Re: Possible data change after file_str_read? [Re: jcl] #306343
01/21/10 10:55
01/21/10 10:55
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline OP
Expert
Helghast  Offline OP
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
LOL! like I said, it was very late, my brain was as dead as it could be...
I assumed file_str_read set's the file read pointer to the position in the file to after the string i passed in there.
instead i needed file_find for that...

Again, very sorry for this stupid bug report, and for wasting your time on this *i feel very very dumb now, hahaha, maybe my title shouldnt say "Expert" :P*

thanks for the help laugh

PS: Now let's see if the bug report of the model crashing gives such a weird user failure as well tongue


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/

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