This commit is contained in:
JustAGenericUsername 2024-05-27 11:36:56 -04:00
parent e06c3bc4bb
commit e5d1d38d3c
3 changed files with 189 additions and 0 deletions

View File

@ -301,6 +301,7 @@
<tr><td>random_liquids.js</td><td>Randomly generates liquids on game load</td><td>Alice</td></tr>
<tr><td>sbmixup.js</td><td>Adds silly elements from a <a href="https://R74n.com/mix/" target="_blank">Mix-Up!</a> game</td><td>stefanblox</td>
<tr><td>star_wars.js</td><td>Adds various items from Star Wars by Disney</td><td>SeaPickle754</td>
<tr><td>subspace.js</td><td>Adds a Subspace Tripmine sound effect when an explosion happens</td><td>nousernamefound</td></tr>
<tr><td>sus.js</td><td>Adds an Among Us crewmate</td><td>Nv7</td></tr>
<tr><td>triggerable_random_powders.js</td><td>Adds powders with different abilities, such as heating and cooling</td><td>Alice</td></tr>
<tr><td>troll.js</td><td>Adds various dumb elements that iterate randomly on the entire screen</td><td>Alice</td></tr>

View File

@ -1,3 +1,169 @@
function getImportantLetters(input) { // entirely chadgbd i just told it what algoritm to make
const isVowel = char => 'AEIOU'.includes(char);
const isConsonant = char => /^[BCDFGHJKLMNPQRSTVWXYZ]$/.test(char);
const removeDuplicates = str => {
let seen = new Set();
return str.split('').filter(char => {
if (seen.has(char)) {
return false;
} else {
seen.add(char);
return true;
}
}).join('');
};
const words = input.replace(/[^a-zA-Z0-9\s_]/g, '').replace(/_/g, ' ').toUpperCase().split(/\s+/);
if (input.length <= 4) {
return input.toUpperCase();
} else if (words.length === 1) {
const word = removeDuplicates(words[0]);
let result = '';
let consonantCount = 0;
let vowelFound = false;
for (let char of word) {
if (isVowel(char) && !vowelFound) {
result += char;
vowelFound = true;
} else if (isConsonant(char) && consonantCount < 3) {
result += char;
consonantCount++;
}
if (result.length === 4) {
break;
}
}
return result.padEnd(4, result[result.length - 1] || '');
} else if (words.length === 2) {
const firstWord = words[0];
const secondWord = words[1];
let result = '';
if (isNaN(firstWord) && !isNaN(secondWord)) {
const word = removeDuplicates(firstWord);
let consonantCount = 0;
let vowelFound = false;
for (let char of word) {
if (isVowel(char) && !vowelFound) {
result += char;
vowelFound = true;
} else if (isConsonant(char) && consonantCount < 2) {
result += char;
consonantCount++;
}
if (result.length === 3) {
break;
}
}
result = result.padEnd(3, result[result.length - 1] || '') + secondWord;
} else if (!isNaN(firstWord) && isNaN(secondWord)) {
const word = removeDuplicates(secondWord);
let consonantCount = 0;
let vowelFound = false;
for (let char of word) {
if (isVowel(char) && !vowelFound) {
result += char;
vowelFound = true;
} else if (isConsonant(char) && consonantCount < 2) {
result += char;
consonantCount++;
}
if (result.length === 3) {
break;
}
}
result = result.padEnd(3, result[result.length - 1] || '') + firstWord;
} else {
result = firstWord[0];
let consonants = [];
let vowels = [];
let allChars = [];
for (let char of secondWord) {
allChars.push(char);
if (isConsonant(char)) {
consonants.push(char);
} else if (isVowel(char)) {
vowels.push(char);
}
}
if (consonants.length >= 3) {
let consonantCount = 0;
for (let char of allChars) {
if (isConsonant(char) && consonantCount < 3) {
result += char;
consonantCount++;
}
if (result.length === 4) {
break;
}
}
} else if (consonants.length === 2) {
let consonantCount = 0;
let vowelCount = 0;
for (let char of allChars) {
if (isConsonant(char) && consonantCount < 2) {
result += char;
consonantCount++;
} else if (isVowel(char) && vowelCount < 1) {
result += char;
vowelCount++;
}
}
} else {
let consonantCount = 0;
let vowelCount = 0;
for (let char of allChars) {
if (isConsonant(char) && consonantCount < 1) {
result += char;
consonantCount++;
} else if (isVowel(char) && vowelCount < 2) {
result += char;
vowelCount++;
}
if (result.length === 4) {
break;
}
}
}
result = result.padEnd(4, result[result.length - 1] || '');
}
return result;
} else if (words.length === 3) {
const firstWord = words[0];
const secondWord = words[1];
const thirdWord = words[2];
let result = firstWord[0] + secondWord[0];
let consonantCount = 0;
let vowelFound = false;
for (let char of thirdWord) {
if (isVowel(char) && !vowelFound) {
result += char;
vowelFound = true;
} else if (isConsonant(char) && consonantCount < 1) {
result += char;
consonantCount++;
}
if (result.length === 4) {
break;
}
}
return result.padEnd(4, result[result.length - 1] || '');
} else {
return words.map(word => word[0]).join('').slice(0, 4);
}
}
function swapObjectValues(obj) {
const keys = Object.keys(obj);
while (keys.length > 1) {
@ -50,12 +216,15 @@ elements.name_settings = {
if (doNameSwapping == "yes"){settings.funnyname.doNameSwapping = true} else {settings.funnyname.doNameSwapping = false}
var doLetterSwapping = prompt("Would you like to swap the letters in the names? Type yes or no.", "no")
if (doLetterSwapping == "yes"){settings.funnyname.doLetterSwapping = true} else {settings.funnyname.doLetterSwapping = false}
var condenseToFour = prompt("Would you like to condense the names to 4 letters? Also known as TPT-ify. Type yes or no.", "no")
if (condenseToFour == "yes"){settings.funnyname.condenseToFour = true} else {settings.funnyname.condenseToFour = false}
var doNameRates = prompt("Would you like to make the names a rating? If yes, this will set all others to no (it is incompatible.) Type yes or no.", "no")
if (doNameRates == "yes"){
settings.funnyname.doNameRates = true
settings.funnyname.doNameSwapping = false
settings.funnyname.doVowelSwapping = false
settings.funnyname.doLetterSwapping = false
settings.funnyname.condenseToFour = false
} else {settings.funnyname.doNameRates = false}
saveSettings()
var allNamesString = prompt("Would you like to set all names to a custom string? This will set all others to no. Type yes or no.", "no")
@ -64,6 +233,7 @@ elements.name_settings = {
settings.funnyname.doNameSwapping = false
settings.funnyname.doVowelSwapping = false
settings.funnyname.doLetterSwapping = false
settings.funnyname.condenseToFour = false
settings.funnyname.doNameRates = false
customName = prompt("What would you like to set the names to?", "")
settings.funnyname.customName = true
@ -138,5 +308,13 @@ runAfterAutogen(
}
}
}
if (settings.funnyname.condenseToFour){
for (let elementname in elements){
if (elementname != "name_settings"){
let newelementname = getImportantLetters((elements[elementname].name)||elementname)
elements[elementname].name = newelementname
}
}
}
}
)

10
mods/subspace.js Normal file
View File

@ -0,0 +1,10 @@
function playSubspace() {
var audio = new Audio("https://JustAGenericUsername.github.io/subspaceboom.mp3");
audio.play();
}
window.addEventListener('load', function() {
const oldexpfunc = explodeAt;
explodeAt = function(x,y,radius,fire="fire"){
oldexpfunc(x,y,radius,fire)
playSubspace()
}})