Hey everyone.
So I was on a long Hiatus for a year and a half before I decided to continue my work on JF Simon. Unfortunately, I am now working on packaging my sounds file into a pack file that the game can use. I will link to a zip folder of everything so that someone can help me. When I run the script as normal via source code or exicutible with all the sounds in the sound folder, everything works fine. But when I set the sound storage to the pack file, I get no sounds and a problem with running the main menu. So I did lots and lots of checking on my code and I simply can not find the solution to this problem. WhIth all that aside, here is the link to the game's source code. I am at the end of my rope right now. https://www.dropbox.com/s/6vgmmx3thhsej … 9.zip?dl=0

Thumbs up

It's clear that this can't work.
First, your pack program is rather inefficient. You type every file name there by hand. Why not use the BGT-internal functions to list all files inside the Sounds folder and add them automatically?
I'd also recommend not to use folders inside the Sounds folder, since folders in pack files can get a little bit tricky.
Now the reason why all this doesn't work in your program. There is so much wrong here which you seemed to mess up...

#include "JF_Simon_Sounds.dat"

This statement will include the pack file into the executable when building it.
The set_sound_storage() function explains that, if you want to access this pack file, you'll have to use "*" as parameter, not the name of the pack file, but you're using the following here:

set_sound_storage("SJ_Simon_Sounds.dat");

You see the problem here? Right, you include the pack file into the executable, but you don't use it here in any case. Instead you use a file with the name SJ_Simon_Sounds.dat which lies in the executable's directory. Or, more understandable, you include the sounds file twice, but use it only once. So you'll have to decide: do you want to include the pack file into the executable? If yes, use set_sound_storage() with "*" here. If not, then remove the include statement for the pack file.

The bigger problem now is the sound loading.
Your file packer includes lines like those:

gamedata.add_file(soundpath+"Error.ogg","errorbuz");

This works, but did you read what this actually does?
It uses the error.ogg file inside the soundpath and adds it, but under another name, namely errorbuz. In your game you then want to load a file located under soundpath and called error.ogg. It's just fair that it cannot find any file there if the sounds folder isn't available anymore, because the function now has to look inside the pack file under the name errorbuz, and how should I know that if you don't tell him that?
That's actually the reason why you're missing any sounds when packing your game and removing the Sounds folder.
Best Regards.
Hijacker

Thumbs up

So I have made some changes. But I'm still stumped.
So I trashed my file Packer and I looked at how to package files. So my question is: If I take my pack file and I want to include it in my executable, Do I still need to have the pack_file.dat in the same as my script source? And then you are saying as I compile the main source file, the pack_file.dat doesn't need to be included anymore? I've also taken all the sounds and eliminated the other folders except for the Holiday one. I want to leave it open to where people can put whatever they want for Christmas, Thanksgiving, etc. And I will be putting subfolders with the names of those Holidays in there.

Thumbs up

audioracer wrote:

So I trashed my file Packer and I looked at how to package files. So my question is: If I take my pack file and I want to include it in my executable, Do I still need to have the pack_file.dat in the same as my script source?

You'll need that, yes, but only at compile time. If you're running the executable after this you won't need this pack file anymore, at least if you're addressing it correctly inside your program.

audioracer wrote:

And then you are saying as I compile the main source file, the pack_file.dat doesn't need to be included anymore?

That depends on how you want to do it. As I already said, you'll have to decide if you want to put the pack file externally into your project or include it directly into the executable. All depends on that choice.

Best Regards.
Hijacker

Thumbs up

OK. As far as files are concerned, I am only doing what the tutorial and object reference layers are telling you to do.
Fore example:

// Create a pack file and add some test files.

void main()
{
pack_file test;
test.create("pack.dat");
test.add_file("test1.txt","t1");
test.add_file("test2.txt","t2");
test.add_file("test3.txt","t3");
test.close();
}

Thumbs up

6 (edited by Hijacker 2017-07-04 20:50:15)

Yeah, but this won't help you very far. The object reference and tutorials will show you what you can do, not what you'll have to do in order to reach your own goals.
You now know that you can give add_file two strings, the first string referencing the file name on hard drive, the second one the entry location inside the pack file.
But if you'll be smart enough to take this as your advantage and get to the idea that you can get all the files you want to pack automatically and add all that in an automated way, instead of typing all that by hand (because that is what programs are designed for) depends on you.
Best Regards.
Hijacker

Thumbs up

OK. I understand that I want to add this in an automated way. So you could you provide a bit of example code for me to look at? That way I can get a better Idea of how to go about this.

Thumbs up

Yep, consider code like this:

void main()
{
  pack_file soundpack;
  string[] sounds;
  uint i;
  sounds=find_files("sounds/*.ogg");
  if(sounds.length()==0)
    return;
  soundpack.create("sounds.dat");
  for(i=0;i<sounds.length();i++)
  {
    soundpack.add_file("sounds/"+sounds[i],sounds[i]);
  }
  soundpack.close();
}

This takes all files inside your sounds folder and throws them into a sounds.dat file.
Best Regards.
Hijacker

Thumbs up

OK thank you for this code. Now as I look at it, I see the path to the sounds folder and the file extension. So instead of writing

greeter[0].stream("Sounds/Greeting1.ogg");

I can now do

greeter[0].stream("Greeting1");

I just want to make sure I understand this correctly.

Thumbs up

That depends on how you name it inside your pack file. My example adds the file under the same name, with extension. Greeting1 wouldn't work for my example, i'd need to be Greeting1.ogg.
Best Regards.
Hijacker

Thumbs up

Thank you to Highjacker for your help in solving this problem. All Files are packed and the program works properly. Next is to deal with stuff in regards to Holidays. If you all have any Holiday cut-seen jingles  that you want to be included in the game, let me know. I'm actually going to leave that part available for people to put whatever they want and so lets say that the date falls under Christmas, people will be able to put whatever they want of the Christmas sub-folder of the Holidays Folder. And the game will randomly choose whatever is in that directory and play it.

Thumbs up