Page 1 of 2

New iPhone GeLoader (Work in Progress)

PostPosted: Wed Nov 02, 2011 4:13 pm
by Fojam
ok so apps in the root /Applications directory can run .sh files as the executable. i dont know yet if they can run that in the mobile directory also, though. this gives me an idea.

we can make a version of geplayer where the first executable is an sh file that scans a folder for its contents. it then lists its contents inside a text file. then it runs the geplayer executable, which runs a dat game. the dat game reads the list of maps from the text file and lists them in the game. when you click on one of them, it loads the game. this will allow people to keep multiple games in their geplayer app!

Re: iPhone idea

PostPosted: Wed Nov 02, 2011 4:15 pm
by CrimsonTheDarkBat
Oh dear god I've gone cross-eyed. :shock: :lol:

Sounds like a good idea though, and would certainly solve a lot of people iPhone woes. ^^

Re: iPhone idea

PostPosted: Wed Nov 02, 2011 4:17 pm
by Fojam
im gonna learn a little sh script and try to make this work

Re: iPhone idea

PostPosted: Wed Nov 02, 2011 4:22 pm
by Hblade
genius.

Re: iPhone idea

PostPosted: Wed Nov 02, 2011 5:30 pm
by akr
You can write a script in game-editor which loads other .dat files. Then you should get the same with minimum effort.

All the other files can be uploaded sequentially to geplayer once.

andreas

Re: iPhone idea

PostPosted: Wed Nov 02, 2011 7:34 pm
by Fojam
akr i want it to list all of the available files so people can choose which one to load

Re: iPhone idea

PostPosted: Thu Nov 03, 2011 12:11 am
by Fojam
ok the sh script is done i just need to make the game editor file. this is the hard part....

what i need to do is make it count the number of lines that are in the text and make that amount of text actors. each text actor will correspond with one of the lines in the text document. when clicked on, that text actor will launch whatever .dat file their line represents.
I need it to skip the first line though, because the first line just says the directory, but thats not super important i could use that to my advantage.

also, here is the apps to run this on iPhone. not yet working it just lists the dat files into a txt file. put your dat files in /geapp.app/games
http://dl.dropbox.com/u/8500676/geapp.zip

this does also require com.conradkramer.open installed on your iPhone

Re: iPhone idea

PostPosted: Thu Nov 03, 2011 12:49 am
by skydereign
You can use a function like this to get the number of lines. The rest is pretty straight forward. You can use fgets to set the text actors.
Code: Select all
#define MAX_LINE 255
int
file_num_lines (FILE* file)
{
    char temp[MAX_LINE];
    int count = 0;
    if(file != NULL)
    {
        while(fgets(temp, MAX_LINE, file)!=NULL)
        {
            count++;
        }
    }
    return count;
}

Re: iPhone idea

PostPosted: Thu Nov 03, 2011 1:00 am
by Fojam
to use that, should i just add one text actor and set it to a create actor event or what?

Re: iPhone idea

PostPosted: Thu Nov 03, 2011 2:10 am
by skydereign
I'd make an array, and use the text actor's cloneindex to set the text (in their create actor event). But, that function wouldn't need to be run all the time. That was just for getting the number of lines.

Re: iPhone idea

PostPosted: Thu Nov 03, 2011 2:12 am
by Fojam
im still learning a lot, so do you think you could make an example? sorry

Re: iPhone idea

PostPosted: Thu Nov 03, 2011 3:56 am
by skydereign
No, I'd rather not make an example, as this doesn't involve very much and and it would be better learning wise if you didn't just see the answer. Anyway, you have a file that you want to read in its lines. You can use a loop (using fgets) and an array of strings, and then you are done. fgets takes a FILE*, a string, and a max line size. It reads in until it reaches a newline (or max line size is met). Each loop increases the index, and so you keep writing in the strings until you reach the end of the file (fgets returns NULL).

Re: iPhone idea

PostPosted: Thu Nov 03, 2011 4:20 pm
by Fojam
ok i tried to use your code and it gave me a ton of errors. im sorry i am still trying to learn a lot of GE's code so i didnt understand a lot of what was written.

Re: New iPhone GeLoader (Work in Progress)

PostPosted: Thu Nov 03, 2011 11:01 pm
by Fojam
ok i think i have it close, but im stuck on something
i want to keep creating new variables for each line in the text file (ie: line1, line2, line3 etc) but i dont know how to do that.

this is what i have so far
Code: Select all
fp = fopen("list.txt", "r");
while(!(feof(fp)))
{
    count++;
    for(i=1; i<=count; i++)
    {
        string sprintf("line%s", i) = fgets(fp);
    }
}

Re: New iPhone GeLoader (Work in Progress)

PostPosted: Fri Nov 04, 2011 12:04 am
by skydereign
The code I provided doesn't have any errors, so something about your setup is messing it up. It does exactly what it should do. Now to address the problems in your code, that isn't how sprintf works, nor are strings supported in C. Also what are you trying to do with that code? It looks like you are trying to read more and more lines from the file each iteration of the loop. If you wanted to read in the line from the file and have it use sprintf, you can do this.
Code: Select all
fgets(str_temp, MAX_LINE, fp);
sprintf(string_var, "line%s", str_temp);