2015-01-27 01:34:13

I want to create a script that will do the following.
1: Locate a pack file on disk via a browse function.
2: Open the pack file and ask for the decryption key, and then use that to decrypt the sounds in the file.
3: Open the contents of the pack file in the same file and folder view mode, allowing you to play and extract files. Press enter to open a menu on the file, where you can open it with bgt if it's a audio file, or extract it to a specified folder on disk.
Also, I wish it was possible to create a pack creater that would allow you to either select files to be added to the pack in a folder file list mode, or just add a folder and all subfolders to the script's pack, folders intacked.
I do sort of know how to create a browse function, thanks to Cae Jones's scripts, browser being one of them. But this thing will not open inside a pack file.

----------
An anomaly in the matrix. An error in existence. A being who cannot get inside the goddamn box! A.K.A. Me.

2015-01-27 21:36:15 (edited by keyIsFull 2015-01-27 21:38:45)

I thought the file browser returned either a file object or a string containing the file path. So you just pass that as a parameter to the browse_pack function. In the function you'd ask the user for the deryption key, then you'd use the list_files method to turn an array containing the files. Create a menu, create the if statements to check if the file is a sound or not, and voila.
Not sure why you would want the pack in the same file/folder browsing mode. It seems kind of impractical to me
Also you mention keeping the same file/folder structure? There is no such thing as a file/folde structure in a pack file.

I like to sleep, Sleep is good,
This is how I do it: Lie on a nice warm cozy bed, and dream dreams about how to rule the world!
Follow @TheGreatAthlon5 on twitter for humorous facts and game updates!
If you like my posts, thumb me up!

2015-01-27 22:09:56

Hi, why can't we add a folder at once to a pack? Also, for example, if we had multiple tpyes of a sound, for example, we have 6 voice folders and all of them has hi.wav, how do we seperate those from eachother? Thank you.

I post sounds I record to freesound. Click here to visit my freesound page
I usually post game recordings to anyaudio. Click here to visit my anyaudio page

2015-01-28 00:04:06

Packs use arbitrary strings to identify files. These can have the same syntax as file/folder paths, but that's purely for convenience.
I don't remember if there's a way to get all the contents of a pack without extracting everything. But once you have the contents, either directly or through extraction, browsing through them and playing them is trivial.
It might be problematic in terms of preserving the folder structure, though.

看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.

2015-01-29 14:46:39

why not just program your own pack generator? It's easy. The way I do it in my game, if you are using a debug version (I.e: source code or compile debug... it will generator. Otherwise, it will open the pack. This is a one-time and forget thing.

ReferenceError: Signature is not defined.

2015-01-30 01:10:48

I'm sorry, I'm kinda new to bgt, and I can barely use arays right now. Here's what I would like to do, for my game. This is target. I want to have a folder called guns in the sounds folder, sounds/guns. I want there to be a select gun sound option, and if you click it, it will browse sounds/guns with find files, return it as an aray, now how do I bring that aray into a dynamic menu with each item as a sound file? For example, default.ogg, rifle.wav, all in the menu.

----------
An anomaly in the matrix. An error in existence. A being who cannot get inside the goddamn box! A.K.A. Me.

2015-01-30 23:09:31

You could use a for loop to add each file to the menu.

What I did when I wanted a sound browser was take my file browser and change it so that pressing enter on a file would play it instead of returning. I don't have that program on this computer, else I'd just upload it for people to play with.

看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.

2015-01-31 01:30:02

so I could create the aray to find files in that directory, then I could use a for loop to say as long as this counter is less than the length of this aray, add a menu item. My question is, how in the hell and I going to make it speak filenames, such as default.ogg, rifle.wav or laser.ogg.

----------
An anomaly in the matrix. An error in existence. A being who cannot get inside the goddamn box! A.K.A. Me.

2015-01-31 02:30:25

if you're using dynamic_menu, the ad_item_tts function returns a string, which basically means you can just use the array created by find_files.

I like to sleep, Sleep is good,
This is how I do it: Lie on a nice warm cozy bed, and dream dreams about how to rule the world!
Follow @TheGreatAthlon5 on twitter for humorous facts and game updates!
If you like my posts, thumb me up!

2015-02-02 05:44:10

I tried that and it said it couldn't return that. I've got menuX, maybe I can just add a counter and count up the aray.

----------
An anomaly in the matrix. An error in existence. A being who cannot get inside the goddamn box! A.K.A. Me.

2015-02-02 15:38:12

Ah.
Try this?
(Haven't actually tested it):

sound_pool pool;
string[] files=find_files("sounds/*");
int n=0;
dynamic_menu menu;
for(uint i=0; i<files.length(); i++) {
menu.add_item_tts(files[i]);
}
while(n>=0) {
n=menu.run();
if(n>=0 and n<files.length()) {
pool.destroy_all(); // Unnecessary, but I find letting sounds overlap when I do this to be annoying at best.
pool.play_stationary("sounds/" + files[n], false);
}

}
看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.

2015-02-06 17:00:50

works! I did a bit of editing, but it works! Now, here's my question. It indeed adds the items, but the problem is that it basses them on 0, so if I press escape it plays the first sound, and every sound is one ahead. Is there a way to fix this? I do know that arays are 0 based, but can you fix this bug with some kind of math?

----------
An anomaly in the matrix. An error in existence. A being who cannot get inside the goddamn box! A.K.A. Me.

2015-02-06 17:16:20

And I kinda wanna use a sound object, as this target game is sound pool based, but I never use play stationery, instead I use sound objects. I know, I'm stupid. That's probably not the way to go. i would not like converting all those sounds from object to pool, as I'd have to rewrite half the game and that thing is already getting huge. I want it to return a filename as a string, and load that into memory. Also, I would like to choose if it should play_wait or just play from the menu, like you select the sound, it loads it, plays it, and asks if it should play wait or play and if you answer play wait, it waits when you shoot. Otherwise, it just plays. I know how to do that, just a bit more if statements. I just need it to play and load the right file, with a sound object. Thank you, sorry if I'm bothering anyone.

----------
An anomaly in the matrix. An error in existence. A being who cannot get inside the goddamn box! A.K.A. Me.

2015-02-08 00:03:18

Hm. I was under the impression that n=-1 was for escape. You can just change this line:
n=menu.run()-1;

You could do it with a sound object, yeah. Are you wanting to use one sound object, or do you want one for each sound?
You would just need to declare a sound object outside of the loop (or globally, if you want to reuse it elsewhere), and replace the sound pool lines with this:
(replace snd with the name of your sound object)

snd.stop();
snd.load(files[n]);
snd.play();

It's important to declare the sound object outside of the loop, otherwise it will be destroyed before it finishes playing, unless you use play_wait.

If you instead want an array to match the filenames, you could create one and initialize it in the same for loop that sets up the menu. In that case, you'd just call sounds[n].play() in place of the pool shenanigans.

看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.

2015-02-10 04:38:11

It plays, now I want a preview function. Um, I need a callback for that so I can press space, and it'll play the sound.

----------
An anomaly in the matrix. An error in existence. A being who cannot get inside the goddamn box! A.K.A. Me.

2015-02-10 18:28:20

Right now, it might be a bit easier and faster for you to simply edit the while loop of the run_extended method of the dynamic_menu include script itself, adding the spacebar press check directly, rather than figuring out the callback stuff. Just a tip.
Lukas

I won't be using this account any more or participating in the forum activity through other childish means like creating an alternate account. I've asked for the account to be removed but I'm not sure if that's actually technically possible here. Just writing this for people to know that I won't be replying, posting new topics or checking private messages until the account is potentially removed.

2015-02-10 20:18:02

Callbacks really aren't that hard, at least they weren't for me. But, I also had been learning bgt for 2 and a half months before even looking at them.

2015-02-14 19:48:16

You could do the following for the menu callback. In this callback example, I'll call your dynamic_menu object just 'menu'.
int menu_callback (dynamic_menu@ menu, string data)
{
if (key_pressed(KEY_SPACE))
{
// code here...
}
// make the menu continue if the if statement does not return any value.
return 0;
}
then, in the menu code:
menu.set_callback(menu_callback, "");
HTH

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.
My Github

2015-02-14 22:06:51

@ethin I have already designed a callback and sent it to Colton.

2015-02-15 04:35:51

thank you all. Well, as you might know if you guys read my threads, target 1. is out!
http://coltonhill01.x10.mx/downloads/Ta … taller.exe
Enjoy!

----------
An anomaly in the matrix. An error in existence. A being who cannot get inside the goddamn box! A.K.A. Me.

2015-02-15 20:52:58

I have a question of operators, I want to perform a complex operation. Is it possible to make it so that I may check if a number is the multiple of something, such as, is this number a multiple of 3, meaning 6, 9, 12, etc?

----------
An anomaly in the matrix. An error in existence. A being who cannot get inside the goddamn box! A.K.A. Me.