-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpack_extracter.nvgt
65 lines (65 loc) · 1.61 KB
/
pack_extracter.nvgt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include"bgt_compat.nvgt"
#include"speech.nvgt"
file temp;
string[] contents;
string filename;
string end;
pack pfile;
string string2file(string thing)
{
thing=string_replace(thing,"\\","/",true);
thing=string_replace(thing,"/"," ",true);
return thing;
}
void main()
{
filename=input_box("pack extracter", "enter the name of the file you wish to extract");
if (filename=="")
{
alert("error!","you may not extract an empty file!");
exit();
}
end=input_box("pack extracter", "Enter anything you want added to the end of the filenames, such as .ogg or .wav.");
if (get_last_error()==-12)
{
exit();
}
pfile.open(filename);
contents=pfile.list_files();
alert("get ready",contents.length()+" files are about to be extracted!");
if (!directory_exists("packs"))
{
directory_create("packs");
}
if (!directory_exists("packs/"+filename))
{
directory_create("packs/"+filename);
}
string output;
double temp=-1;
show_game_window("working");
for (double i=0; i<contents.length(); i++)
{
double percent=(i+1)/contents.length()*100.0;
percent=round(percent,0);
if(percent!=temp)
{
speak(percent+" percent");
temp=percent;
}
output+=contents[i]+"\r\n";
extract_file(pfile,contents[i], "packs/"+filename+"/"+string2file(contents[i])+end);
}
directory_delete("packs/"+filename+"/decrypted");
//clipboard_copy_text(output);
alert("success",filename+" has been extracted. stats: "+contents.length()+" files are now in packs/"+filename);
}
void extract_file(pack@ pf, const string&in filename, const string&in outfile)
{
uint size=pf.get_file_size(filename);
string content=pf.read_file(filename,0,size);
file t;
t.open(outfile,"wb");
t.write(content);
t.close();
}