Undepreciated adjustable heater/cooler + 1 more element

This commit is contained in:
Cube14yt 2026-02-02 14:04:25 +08:00 committed by GitHub
parent b7d5516a00
commit 5a239701ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 69 additions and 97 deletions

View File

@ -1,7 +1,7 @@
/* /*
Use intellisense for sandboxels modding here: Use intellisense for sandboxels modding here:
to show availavle functions and show global variables to show availavle functions and show global variables
https://github.com/Cube14yt/sandboxels-types https://github.com/R74nCom/sandboxels-types
*/ */
@ -619,37 +619,6 @@ elements.glow_stick_ice = {
state: "solid" state: "solid"
} }
// Add TPS keybind
keybinds["KeyT"] = function () {
tpsPrompt()
}
function addRowWhenReady() {
const table = document.getElementById("controlsTable");
if (!table) {
// Table not ready yet, try again in 100ms
setTimeout(addRowWhenReady, 100);
return;
}
// Table exists, add the row
const rowCount = table.rows.length;
const newRow = table.insertRow(rowCount - 1);
const cell1 = newRow.insertCell(0);
const cell2 = newRow.insertCell(1);
cell1.textContent = "Change TPS";
cell2.innerHTML = "<kbd>T</kbd>";
console.log("Row added successfully!");
}
// Start the process
addRowWhenReady();
elements.randomizer = { elements.randomizer = {
buttonColor: rainbowColor, buttonColor: rainbowColor,
excludeRandom: true, excludeRandom: true,
@ -794,32 +763,32 @@ elements.rgb_led = {
stateHigh: ["molten_glass", "molten_glass", "molten_glass", "molten_gallium"], stateHigh: ["molten_glass", "molten_glass", "molten_glass", "molten_gallium"],
onSelect: () => { onSelect: () => {
promptInput("Enter red value (0-255):", function (r_inp) { promptInput("Enter red value (0-255):", function (old_r_inp) {
r_inp = parseInt(r_inp); let r_inp = parseInt(old_r_inp);
if (r_inp > 255 || r_inp < 0 || isNaN(r_inp)) { if (r_inp > 255 || r_inp < 0 || isNaN(r_inp)) {
logMessage("Red value is invalid, using default/last red value: " + globals.red); logMessage("Red value is invalid, using default/last red value: " + globals.red);
} else { } else {
globals.red = r_inp; globals.red = r_inp;
} }
promptInput("Enter green value (0-255):", function (g_inp) { promptInput("Enter green value (0-255):", function (old_g_inp) {
g_inp = parseInt(g_inp); let g_inp = parseInt(old_g_inp);
if (g_inp > 255 || g_inp < 0 || isNaN(g_inp)) { if (g_inp > 255 || g_inp < 0 || isNaN(g_inp)) {
logMessage("Green value is invalid, using default/last green value: " + globals.green); logMessage("Green value is invalid, using default/last green value: " + globals.green);
} else { } else {
globals.green = g_inp; globals.green = g_inp;
} }
promptInput("Enter blue value (0-255):", function (b_inp) { promptInput("Enter blue value (0-255):", function (old_b_inp) {
b_inp = parseInt(b_inp); let b_inp = parseInt(old_b_inp);
if (b_inp > 255 || b_inp < 0 || isNaN(b_inp)) { if (b_inp > 255 || b_inp < 0 || isNaN(b_inp)) {
logMessage("Blue value is invalid, using default/last blue value: " + globals.blue); logMessage("Blue value is invalid, using default/last blue value: " + globals.blue);
} else { } else {
globals.blue = b_inp; globals.blue = b_inp;
} }
}, "Blue Value", globals.blue); // optional default input }, "Blue Value", String(globals.blue)); // optional default input
}, "Green Value", globals.green); }, "Green Value", String(globals.green));
}, "Red Value", globals.red); }, "Red Value", String(globals.red));
}, },
onPlace: (pixel) => { onPlace: (pixel) => {
@ -1763,7 +1732,7 @@ globals.heatAmount = 2
elements.adjustable_heater = { elements.adjustable_heater = {
color: "#ff0000", color: "#ff0000",
category: "deprecated", category: "machines",
insulate: true, insulate: true,
behavior: behaviors.WALL, behavior: behaviors.WALL,
@ -1846,7 +1815,7 @@ globals.coolAmount = 2; // adjustable step
elements.adjustable_cooler = { elements.adjustable_cooler = {
color: "#0000ff", color: "#0000ff",
category: "deprecated", category: "machines",
insulate: true, insulate: true,
behavior: behaviors.WALL, behavior: behaviors.WALL,
@ -2374,6 +2343,7 @@ elements.cacao_stem = {
// --- audio setup --- // --- audio setup ---
// @ts-ignore
const audioCtx = new (window.AudioContext || window.webkitAudioContext)(); const audioCtx = new (window.AudioContext || window.webkitAudioContext)();
function playNote(frequency, duration = 1, type = "sine", volume = 0.1) { function playNote(frequency, duration = 1, type = "sine", volume = 0.1) {
@ -2738,13 +2708,18 @@ globals.rCircle = false
globals.rRGBLed = false globals.rRGBLed = false
globals.rCustomBomb = false globals.rCustomBomb = false
dependOn("betterSettings.js", () => { dependOn("betterSettings.js", () => {
// @ts-ignore
var Reset = new SettingsTab("Reset"); var Reset = new SettingsTab("Reset");
// @ts-ignore
var resetCircle = new Setting("Reset circle value and radius on reset", "Reset circle", settingType.BOOLEAN, false, defaultValue = false); var resetCircle = new Setting("Reset circle value and radius on reset", "Reset circle", settingType.BOOLEAN, false, defaultValue = false);
// @ts-ignore
var resetRGBLed = new Setting("Reset RGB Led value on reset", "Reset RGB Led", settingType.BOOLEAN, false, defaultValue = false); var resetRGBLed = new Setting("Reset RGB Led value on reset", "Reset RGB Led", settingType.BOOLEAN, false, defaultValue = false);
// @ts-ignore
var resetCustomBomb = new Setting("Reset Custom Bomb value on reset", "Reset Custom Bomb", settingType.BOOLEAN, false, defaultValue = false); var resetCustomBomb = new Setting("Reset Custom Bomb value on reset", "Reset Custom Bomb", settingType.BOOLEAN, false, defaultValue = false);
Reset.registerSettings("Reset", resetRGBLed) Reset.registerSettings("Reset", resetRGBLed)
Reset.registerSettings("Reset", resetCircle) Reset.registerSettings("Reset", resetCircle)
Reset.registerSettings("Reset", resetCustomBomb) Reset.registerSettings("Reset", resetCustomBomb)
// @ts-ignore
settingsManager.registerTab(Reset); settingsManager.registerTab(Reset);
runEveryTick(() => { runEveryTick(() => {
if (resetCircle.value == true) { if (resetCircle.value == true) {
@ -3032,7 +3007,7 @@ elements.calculator = {
logMessage("Error") logMessage("Error")
return; return;
} }
logMessage(Number(ans.toFixed(10))) logMessage(ans.toFixed(10))
} }
catch (e) { catch (e) {
logMessage("Invalid Characters Detected") logMessage("Invalid Characters Detected")
@ -3065,8 +3040,9 @@ elements.random_teleporter = {
} else pixel.fadeTo = "orange"; } else pixel.fadeTo = "orange";
} }
for (var i = 0; i < squareCoords.length; i++) { shuffleArray(squareCoordsShuffle)
let coord = squareCoords[i]; for (var i = 0; i < squareCoordsShuffle.length; i++) {
let coord = squareCoordsShuffle[i];
let x = pixel.x + coord[0]; let x = pixel.x + coord[0];
let y = pixel.y + coord[1]; let y = pixel.y + coord[1];
if (!isEmpty(x, y)) { if (!isEmpty(x, y)) {
@ -3248,56 +3224,6 @@ elements.element_line = {
} }
} }
function getSquareCoords(pixel) {
let x, y;
for (let i = 0; i < squareCoords.length; i++) {
let coord = squareCoords[i];
x = pixel.x + coord[0];
y = pixel.y + coord[1];
}
return { x, y }
}
function getAdjacentCoords(pixel) {
let x, y;
for (let i = 0; i < adjacentCoords.length; i++) {
x = pixel.x + adjacentCoords[i][0];
y = pixel.y + adjacentCoords[i][1];
}
return { x, y }
}
function getSquareCoordsShuffle(pixel) {
shuffleArray(squareCoordsShuffle);
let x, y;
for (var i = 0; i < squareCoordsShuffle.length; i++) {
var coord = squareCoordsShuffle[i];
x = pixel.x + coord[0];
y = pixel.y + coord[1];
}
return { x, y }
}
function getAdjacentCoordsShuffle(pixel) {
shuffleArray(adjacentCoordsShuffle)
let x, y
for (var i = 0; i < adjacentCoordsShuffle.length; i++) {
x = pixel.x + adjacentCoordsShuffle[i][0];
y = pixel.y + adjacentCoordsShuffle[i][1];
}
return { x, y }
}
function getScreenCoords() {
let coords = []
for (let x = 0; x <= width; x++) {
for (let y = 0; y <= height; y++) {
coords.push([x, y])
}
}
return coords
}
globals.replaceElem = "wood" globals.replaceElem = "wood"
elements.replace_all_of_element = { elements.replace_all_of_element = {
color: ["#35008a", "#000000"], color: ["#35008a", "#000000"],
@ -3325,5 +3251,51 @@ elements.replace_all_of_element = {
} }
} }
/**
*
* @param {(pixel: Pixel | undefined) => void} callback
*/
function forEachPixel(callback) {
for (let x = 0; x <= width; x++) {
for (let y = 0; y <= height; y++) {
callback(pixelMap[x][y])
}
}
}
elements["🐔poolnoodle"] = {
category: "extras",
color: ["#7700ff", "#90ff90", "#ff0000", "#f700ff"],
buttonColor: rainbowColor,
behavior: behaviors.STURDYPOWDER,
density: 30,
properties: {
panic: 0,
panicTimer: 0
},
onClicked(pixel) {
pixel.panic = 1
pixel.panicTimer = 60
},
tick(pixel) {
if (Math.random() < 0.002) {
if (Math.random() <= 0.1 && (getPixel(pixel.x, pixel.y - 1) || outOfBounds(pixel.x, pixel.y + 1))) {
tryMove(pixel, pixel.x, pixel.y - 2) // 2 to coutneract gravity
}
Math.random() < 0.5
? tryMove(pixel, pixel.x + 1, pixel.y)
: tryMove(pixel, pixel.x - 1, pixel.y);
}
if (!pixel.panic) return
if (pixel.panicTimer <= 0) {
pixel.panic = 0
}
pixel.panicTimer--
if (Math.random() <= 0.1 && (getPixel(pixel.x, pixel.y - 1) || outOfBounds(pixel.x, pixel.y + 1))) {
tryMove(pixel, pixel.x, pixel.y - 2) // same as above
}
if (Math.random() <= 0.7) {
Math.random() <= 0.5 ? tryMove(pixel, pixel.x + 1, pixel.y) : tryMove(pixel, pixel.x - 1, pixel.y)
}
}
}