Merge branch 'R74nCom:main' into main

This commit is contained in:
Nekonico 2025-04-04 22:03:33 -07:00 committed by GitHub
commit 6c8a3362a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 70 additions and 5 deletions

View File

@ -4,7 +4,7 @@
// If elem1 exists
if (elements[key].reactions[reaction].elem1) {
// If elem1 is an array, loop through each element, else check once. Don't delete if it === null
if (Array.isArray(elements[key].reactions[reaction].elem1)) {
if (Array.isArray(elements[key].reactions[reaction].elem1)) {
for (var i = 0; i < elements[key].reactions[reaction].elem1.length; i++) {
if (elements[key].reactions[reaction].elem1[i] && !elements[elements[key].reactions[reaction].elem1[i]]) {
elements[key].reactions[reaction].elem1.splice(i,1);
@ -101,4 +101,4 @@
else {
if (elements[key].breakInto[i]!==null && !elements[elements[key].breakInto]) { delete elements[key].breakInto; }
}
}
}

View File

@ -13048,6 +13048,10 @@ onAddElementList = [];
function onAddElement(callback) {
onAddElementList.push(callback);
}
validateMovesList = [];
function validateMoves(callback) {
validateMovesList.push(callback);
}
canvasLayers = {
// bg: document.createElement("canvas"),
pixels: document.createElement("canvas"),
@ -13764,6 +13768,16 @@ function langKey(key,fallback,template) {
function tryMove(pixel,nx,ny,leaveBehind,force) {
if (pixel.drag && force !== true) { return true; }
if (pixel.del) { return false }
if (validateMovesList.length !== 0 && force !== true) {
for (let i = 0; i < validateMovesList.length; i++) {
const result = validateMovesList[i](pixel,nx,ny);
if (result === false) return false;
else if (Array.isArray(result)) {
nx = result[0];
ny = result[1];
}
}
}
var info = elements[pixel.element];
var oob = outOfBounds(nx,ny);
if (isEmpty(nx,ny,false,oob)) { // If coords is empty, move to coords
@ -18576,7 +18590,7 @@ window.onload = function() {
</div>
<script>
// if it is the 1st of April, add a rainbow-colored button
if (true || new Date().getMonth() == 3 && new Date().getDate() <= 3) {
if (new Date().getMonth() == 3 && new Date().getDate() <= 3) {
// if url contains "fools=true"
if (!window.location.href.includes("fools=true")) {
var foolsButton = `<button id="foolsButton" title="Enable FOOLS Mode" class="controlButton" onclick="window.location.href = '?fools=true'" style="background: linear-gradient(90deg, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #9400d3); background-size: 800% 800%; animation: rainbow 15s ease infinite; -webkit-background-clip: text; -webkit-text-fill-color: transparent; border-color: #ff00ff; outline: none; text-shadow: 0px 0px 10px #ff00ff;">Fools</button>`

51
mods/gravity_test.js Normal file
View File

@ -0,0 +1,51 @@
// validateMoves((pixel,nx,ny) => {
// if (pixel.y-ny < 0) { //goes down usually
// return false;
// }
// })
validateMoves((pixel,nx,ny) => {
if (elements[pixel.element].isGas) return true;
if (true || pixel.y-ny < 0) { //goes down usually
nx = 0;
ny = 0;
const centerX = Math.floor(width/2);
const centerY = Math.floor(height/2);
let diffX = centerX-pixel.x;
let diffY = centerY-pixel.y;
let dirX = 0;
let dirY = 0;
if (Math.abs(diffX) > Math.abs(diffY)) {
dirX = Math.sign(diffX);
}
else {
dirY = Math.sign(diffY);
}
if (Math.random() < Math.abs(diffX)/100) diffX = Math.sign(diffX);
else diffX = 0;
if (Math.random() < Math.abs(diffY)/100) diffY = Math.sign(diffY);
else diffY = 0;
if ((diffX || diffY) && !isEmpty(pixel.x+diffX,pixel.y+diffY)) {
if (dirX !== 0) {
diffY = Math.random() < 0.5 ? 1 : -1;
}
else if (dirY !== 0) {
diffX = Math.random() < 0.5 ? 1 : -1;
}
}
// if (!(pixel.y-ny)) {
// diffX += pixel.y-ny;
// diffY += pixel.x-nx;
// }
return [pixel.x+diffX,pixel.y+diffY];
}
})

View File

@ -3939,7 +3939,7 @@ renderPostPixel(function(ctx){
if ((pixel.element == "sign") && pixel.sign){
ctx.font = `12pt Arial`
ctx.fillStyle = pixel.color;
ctx.fillText(pixel.sign = pixel.sign.replace(/\$\{([\w.\[\]]+)\}/g, (_, path) => {
ctx.fillText(pixel.sign.replace(/\$\{([\w.\[\]]+)\}/g, (_, path) => {
try {
const value = new Function('return globalThis.' + path)();
return typeof value === 'object' ? JSON.stringify(value) : value ?? '';
@ -3951,7 +3951,7 @@ renderPostPixel(function(ctx){
if (pixel.charge || pixel.chargeCD){
ctx.font = `12pt Arial`
ctx.fillStyle = pixel.color;
ctx.fillText(pixel.sign = pixel.sign.replace(/\$\{([\w.\[\]]+)\}/g, (_, path) => {
ctx.fillText(pixel.sign.replace(/\$\{([\w.\[\]]+)\}/g, (_, path) => {
try {
const value = new Function('return globalThis.' + path)();
return typeof value === 'object' ? JSON.stringify(value) : value ?? '';