Skip to content

Commit

Permalink
Upload 1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Matto58 authored Nov 5, 2022
1 parent 1528fc5 commit aed21b1
Showing 1 changed file with 42 additions and 10 deletions.
52 changes: 42 additions & 10 deletions moai.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,75 @@ var file = process.argv[2];
var fileout = process.argv[3] + ".🗿";
var contents = fs.readFileSync(file).toString().split(";");
var output = "";

function replaceV2(str, replaceThese, withThis) {
for (let i in str)
for (let j in replaceThese)
if (str[i] == replaceThese[j]) str[i] = withThis;
return str;
}

// console.log(contents);
for (var i = 0; i < contents.length-1; i++) {
var line = contents[i].split(" ");
var command = line[0];
var lineletters = line[0].split("");
if (command == "Sound" || command == " Sound" || command == "\r\nSound" || command == "\nSound" || command == "\tSound") {
var command = line[0].replace(/(\r\n|\r|\n|\t)/g, "");
if (command == "Sound") {
var sound = line[1];
var pitch = line[2];
output += sound;

if (pitch == undefined || pitch == null) pitch = 0;
if (pitch != "0") output += "@" + pitch;
output += "|";
} else if (command == "Loop" || command == " Loop" || command == "\r\nLoopSound" || command == "\nLoopSound" || command == "\tLoopSound") {
} else if (command == "Loop") {
var amt = line[1];
output += "!loopmany@" + amt + "|";
} else if (command == "LoopPoint" || command == " LoopPoint" || command == "\r\nLoopPoint" || command == "\nLoopPoint" || command == "\tLoopPoint") {
} else if (command == "LoopOnce") {
output += "!loop|";
} else if (command == "LoopPoint") {
output += "!looptarget|";
} else if (command == "BPM" || command == " BPM" || command == "\r\nBPM" || command == "\nBPM" || command == "\tBPM") {
} else if (command == "BPM") {
var bpm = line[1];
var use = line[2];
var u = "";
if (use != "=" && (use == "+" || use == "x"))
u = "@" + use;
output += "!speed@" + bpm + u + "|";
} else if (command == "StartPosition" || command == " StartPosition" || command == "\r\nStartPosition" || command == "\nStartPosition" || command == "\tStartPosition") {
} else if (command == "StartPosition") {
output += "!startpos|";
} else if (command == "Volume" || command == " Volume" || command == "\r\nVolume" || command == "\nVolume" || command == "\tVolume") {
} else if (command == "Volume") {
var vol = line[1];
output += "!volume@" + vol + "|";
} else if (command == "Pause" || command == " Pause" || command == "\r\nPause" || command == "\nPause" || command == "\tPause") {
} else if (command == "Pause") {
var amt = line[1];
if (amt == "1") output += "_pause|";
else output += "_pause=" + amt + "|";
} else if (command == "<=>" || command == " <=>" || command == "\r\n<=>" || command == "\n<=>" || command == "\t<=>") {
} else if (command == "<=>") {
var amt = line[1];
output += "!combine|";
} else if (command == "Background") {
var color = line[1];
var fadeTime = line[2];
output += "!bg@#" + color + "," + fadeTime + "|";
} else if (command == "Transpose") {
var amt = line[1].substring(1);
output += "!transpose@" + amt + "@" + line[1].charAt(0) + "|";
} else if (command == "Pulse") {
var amt = line[1];
var every = line[2];
output += "!pulse@" + amt + "," + every + "|";
} else if (command == "Divider") {
output += "!divider|";
} else if (command == "Target") {
var num = line[1];
output += "!target@" + num + "|";
} else if (command == "GotoTarget") {
var num = line[1];
output += "!jump@" + num + "|";
} else if (command == "StopSounds") {
output += "!cut|";
} else if (command == "Flash") {
output += "!flash|";
} else {
console.log("Unknown command: " + command);
}
Expand Down

0 comments on commit aed21b1

Please sign in to comment.