Bennu Game Development

English Forums => Helpdesk => Topic started by: MisterN on April 11, 2013, 11:24:43 PM

Title: i forget how it's done: read lines from .txt
Post by: MisterN on April 11, 2013, 11:24:43 PM
i forgot how it's done since I haven't used it in awhile and I can't find the thread that had the information and how to use it. how can I read this .txt file:
Quote*moving left
left
*moving right
right
*shooting
control
*jumping
alt
Quote
and putting each line into string conkey[8];
thanks
Title: Re:i forget how it's done: read lines from .txt
Post by: handsource-dyko on April 12, 2013, 07:15:01 AM

something a bit like this (more or less)



textfile_id = fopen ("commands.txt", O_READ);


for (c = 0; c < 8; c++)
     conkey [c] = fgets (textfile_id);
end
   
fclose (textfile_id);
[size=78%]




b.t.w. do also mean to interpret the commands? you can use the strcasecmp() or find() functions to test if line contains valid input, and act accordingly.

[/size]
Title: Re:i forget how it's done: read lines from .txt
Post by: MisterN on April 12, 2013, 12:34:43 PM
i am using this
menu.conkey_map = fopen("conkey.txt", O_READ);
for (c = 0; c < 8; c++)
     conkey [c] = fgets(menu.conkey_map);
end 
fclose(menu.conkey_map);

it says it does not know what o_read is. these are what i have loaded in the beginning
import "mod_grproc";
import "mod_wm"
import "mod_key"
import "mod_proc"
import "mod_video"
import "mod_text"
import "mod_map"
import "mod_draw"
import "mod_debug"
import "mod_say";
import "mod_screen";
import "mod_math";
import "mod_time";
import "mod_dir";
import "mod_joy";
import "mod_sound";
import "mod_rand";


thanks
Title: Re:i forget how it's done: read lines from .txt
Post by: panreyes on April 12, 2013, 12:50:29 PM
mod_file :)
Title: Re:i forget how it's done: read lines from .txt
Post by: MisterN on April 13, 2013, 01:28:19 AM
thank you very much. ive been working on my engine in bits, and when i finish every little detail of each part, ill join them together. ive learned my lesson on that lol xD
Title: Re:i forget how it's done: read lines from .txt
Post by: handsource-dyko on April 13, 2013, 10:15:53 AM
Joining things together. That's an exciting part, that's where the design of a project starts to show it's effect. I've learned my lessons too.
I have started a new project because my editor's gui is showing it's limitations. I have just started on creating a simple gui library but it's in a very early stage. But I'm not sure of it will have textinput because it's kinda complicated to get right. I am waiting for a new version of the android packager so I can finally get malvado on android. (samsung has recently updated my devices to android 4.1).