-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
100 lines (86 loc) · 3.46 KB
/
Copy pathscript.js
File metadata and controls
100 lines (86 loc) · 3.46 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
function removeLineBreaks() {
const input = document.getElementById("input").value.trim();
if (!input) return; // Prevent errors on empty input
const output = input.replace(/(\r\n|\n|\r)/g, ""); // Remove all line breaks
return output;
}
function convertToLua() {
const input = removeLineBreaks();
const bpm = document.getElementById("bpmInput").value || 120; // Get BPM value
if (!input) return; // Prevent errors on empty input
let luaScript = 'loadstring(game:HttpGet("https://github.com/hellohellohell012321/TALENTLESS/main/loader_main.lua"))()\n\n';
luaScript += `bpm = ${bpm}\n\n`; // Add the BPM line to the output
let section = 1;
const lines = input.split("\n");
lines.forEach(line => {
line = line.trim();
if (line === "") return; // Skip empty lines
luaScript += `\n-- ${section}\n\n`;
section++;
let i = 0;
while (i < line.length) {
let note = "";
if (line[i] === "[") {
// Handle square bracketed groups as a single keypress
i++; // Move past '['
while (i < line.length && line[i] !== "]") {
note += line[i];
i++;
}
i++; // Move past ']'
} else {
// Single character note
note = line[i];
i++;
}
// Determine rest duration and count dashes
let dashCount = 0;
while (i < line.length && line[i] === "-") {
dashCount++;
i++;
}
luaScript += `keypress("${note}", 0.25, bpm)\n`;
// Call rest() for the number of dashes found
for (let j = 0; j < dashCount; j++) {
luaScript += `rest(1, bpm)\n`;
}
// Handle spaces as a shorter rest
if (i < line.length && line[i] === " ") {
luaScript += `rest(0.5, bpm)\n`;
i++;
} else if (i < line.length && line[i] === ".") {
luaScript += `rest(0.75, bpm)\n`;
i++; // Move past the period
} else if (i < line.length && line[i] === ",") {
luaScript += `rest(0.333, bpm)\n`;
i++; // Move past the comma
} else if (i < line.length && line[i] === ";") {
luaScript += `rest(0.125, bpm)\n`;
i++; // Move past the comma
} else if (dashCount === 0) {
luaScript += `rest(0.25, bpm)\n`;
}
}
});
document.getElementById("output").innerText = luaScript;
}
function copyOutput() {
const output = document.getElementById("output");
const range = document.createRange();
range.selectNode(output);
window.getSelection().removeAllRanges();
window.getSelection().addRange(range);
document.execCommand("copy");
}
function downloadOutput() {
const output = document.getElementById("output").innerText;
const blob = new Blob([output], { type: "text/plain" });
const url = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
link.download = "vp2lua_output.lua";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
URL.revokeObjectURL(url);
}