Merge pull request #1352 from Cube14yt/extra1
Undepreciated adjustable heater/cooler + 1 more element
This commit is contained in:
commit
ee605ef7e4
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Use intellisense for sandboxels modding here:
|
||||
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"
|
||||
}
|
||||
|
||||
// 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 = {
|
||||
buttonColor: rainbowColor,
|
||||
excludeRandom: true,
|
||||
|
|
@ -794,32 +763,32 @@ elements.rgb_led = {
|
|||
stateHigh: ["molten_glass", "molten_glass", "molten_glass", "molten_gallium"],
|
||||
|
||||
onSelect: () => {
|
||||
promptInput("Enter red value (0-255):", function (r_inp) {
|
||||
r_inp = parseInt(r_inp);
|
||||
promptInput("Enter red value (0-255):", function (old_r_inp) {
|
||||
let r_inp = parseInt(old_r_inp);
|
||||
if (r_inp > 255 || r_inp < 0 || isNaN(r_inp)) {
|
||||
logMessage("Red value is invalid, using default/last red value: " + globals.red);
|
||||
} else {
|
||||
globals.red = r_inp;
|
||||
}
|
||||
|
||||
promptInput("Enter green value (0-255):", function (g_inp) {
|
||||
g_inp = parseInt(g_inp);
|
||||
promptInput("Enter green value (0-255):", function (old_g_inp) {
|
||||
let g_inp = parseInt(old_g_inp);
|
||||
if (g_inp > 255 || g_inp < 0 || isNaN(g_inp)) {
|
||||
logMessage("Green value is invalid, using default/last green value: " + globals.green);
|
||||
} else {
|
||||
globals.green = g_inp;
|
||||
}
|
||||
|
||||
promptInput("Enter blue value (0-255):", function (b_inp) {
|
||||
b_inp = parseInt(b_inp);
|
||||
promptInput("Enter blue value (0-255):", function (old_b_inp) {
|
||||
let b_inp = parseInt(old_b_inp);
|
||||
if (b_inp > 255 || b_inp < 0 || isNaN(b_inp)) {
|
||||
logMessage("Blue value is invalid, using default/last blue value: " + globals.blue);
|
||||
} else {
|
||||
globals.blue = b_inp;
|
||||
}
|
||||
}, "Blue Value", globals.blue); // optional default input
|
||||
}, "Green Value", globals.green);
|
||||
}, "Red Value", globals.red);
|
||||
}, "Blue Value", String(globals.blue)); // optional default input
|
||||
}, "Green Value", String(globals.green));
|
||||
}, "Red Value", String(globals.red));
|
||||
},
|
||||
|
||||
onPlace: (pixel) => {
|
||||
|
|
@ -1763,7 +1732,7 @@ globals.heatAmount = 2
|
|||
|
||||
elements.adjustable_heater = {
|
||||
color: "#ff0000",
|
||||
category: "deprecated",
|
||||
category: "machines",
|
||||
insulate: true,
|
||||
behavior: behaviors.WALL,
|
||||
|
||||
|
|
@ -1846,7 +1815,7 @@ globals.coolAmount = 2; // adjustable step
|
|||
|
||||
elements.adjustable_cooler = {
|
||||
color: "#0000ff",
|
||||
category: "deprecated",
|
||||
category: "machines",
|
||||
insulate: true,
|
||||
behavior: behaviors.WALL,
|
||||
|
||||
|
|
@ -2374,6 +2343,7 @@ elements.cacao_stem = {
|
|||
|
||||
|
||||
// --- audio setup ---
|
||||
// @ts-ignore
|
||||
const audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
||||
|
||||
function playNote(frequency, duration = 1, type = "sine", volume = 0.1) {
|
||||
|
|
@ -2738,13 +2708,18 @@ globals.rCircle = false
|
|||
globals.rRGBLed = false
|
||||
globals.rCustomBomb = false
|
||||
dependOn("betterSettings.js", () => {
|
||||
// @ts-ignore
|
||||
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);
|
||||
// @ts-ignore
|
||||
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);
|
||||
Reset.registerSettings("Reset", resetRGBLed)
|
||||
Reset.registerSettings("Reset", resetCircle)
|
||||
Reset.registerSettings("Reset", resetCustomBomb)
|
||||
// @ts-ignore
|
||||
settingsManager.registerTab(Reset);
|
||||
runEveryTick(() => {
|
||||
if (resetCircle.value == true) {
|
||||
|
|
@ -3032,7 +3007,7 @@ elements.calculator = {
|
|||
logMessage("Error")
|
||||
return;
|
||||
}
|
||||
logMessage(Number(ans.toFixed(10)))
|
||||
logMessage(ans.toFixed(10))
|
||||
}
|
||||
catch (e) {
|
||||
logMessage("Invalid Characters Detected")
|
||||
|
|
@ -3065,8 +3040,9 @@ elements.random_teleporter = {
|
|||
} else pixel.fadeTo = "orange";
|
||||
}
|
||||
|
||||
for (var i = 0; i < squareCoords.length; i++) {
|
||||
let coord = squareCoords[i];
|
||||
shuffleArray(squareCoordsShuffle)
|
||||
for (var i = 0; i < squareCoordsShuffle.length; i++) {
|
||||
let coord = squareCoordsShuffle[i];
|
||||
let x = pixel.x + coord[0];
|
||||
let y = pixel.y + coord[1];
|
||||
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"
|
||||
elements.replace_all_of_element = {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue