Merge pull request #1241 from theenchantedsword/main

Big update
This commit is contained in:
slweeb 2025-09-15 22:03:14 -04:00 committed by GitHub
commit 0cd465e63f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 3365 additions and 2317 deletions

View File

@ -196,7 +196,7 @@
<tr><td>texturepack.js</td><td>Tools that let you create and share custom texture packs</td><td>nousernamefound</td></tr>
<tr><td>the_ground.js</td><td>Several rock types, worldgen settings, and gemstones</td><td>Alice</td></tr>
<tr><td>worldEdit.js</td><td>Selection and editing tools</td><td>RedBirdly</td></tr>
<tr><td>worldgenlibrary.js</td><td>World generation library</td><td>Adora</td></tr>
<tr><td>worldgenlibrary.js</td><td>World generation library</td><td>Orchid</td></tr>
<!----><tr><td class="modCat" colspan="3">Science & Chemistry</td></tr><!---->
<tr><td>alcohol.js</td><td>Methanol, (iso-)propanol, and butanol</td><td>Alice</td></tr>
@ -234,7 +234,7 @@
<tr><td>metals.js</td><td>Several metals</td><td>Alice</td></tr>
<tr><td>mixture.js</td><td>Many chemicals can be mixed</td><td>lllllllllwith10ls</td></tr>
<tr><td>more_gold.js</td><td>Green Gold</td><td>pixelegend4</td></tr>
<tr><td>morechemistry.js</td><td>New chemicals, compounds, and machines</td><td>Adora</td></tr>
<tr><td>morechemistry.js</td><td>New chemicals, compounds, and machines</td><td>Orchid</td></tr>
<tr><td>moreliquids.js</td><td>Various liquids</td><td>te-agma-at</td></tr>
<tr><td>neutronium_compressor.js</td><td>Compressor from Minecraft's Avaritia mod that compresses 10,000 pixels of an element into a singularity</td><td>Alice</td></tr>
<tr><td>noblegas.js</td><td>The missing noble gases</td><td>nousernamefound</td></tr>
@ -253,6 +253,7 @@
<tr><td>colored_lightbulbs.js</td><td>Light bulb that can be painted</td><td>guzzo86, ggod</td></tr>
<tr><td>combustion.js</td><td>Components necessary for combustion engines</td><td>uptzik</td></tr>
<tr><td>conveyance.js</td><td>Conveyors, operated with and without electricity</td><td>Melecie</td></tr>
<tr><td>datawire.js</td><td>Adds a wire that transfers data and other operators and machines for it</td><td>Orchid</td></tr>
<tr><td>drill.js</td><td>Drills made out of several materials</td><td>Suss</td></tr>
<tr><td>ExtraMachines.js</td><td>Sensors, energy resources, materials, and more</td><td>Mecoolnotcool</td></tr>
<tr><td>fans.js</td><td>Fans</td><td>Cube14yt</td></tr>
@ -350,7 +351,7 @@
<tr><td>ocean.js</td><td>Marine life</td><td>SquareScreamYT</td></tr>
<tr><td>ores.js</td><td>Ore generation along with tools to mine them</td><td>nousernamefound</td></tr>
<tr><td>petal_dye.js</td><td>Boil petals to make dye</td><td>Suss</td></tr>
<tr><td>plants.js</td><td>Wide variety of new plants and fruits</td><td>Adora</td></tr>
<tr><td>plants.js</td><td>Wide variety of new plants and fruits</td><td>Orchid</td></tr>
<tr><td>primordial_birthpool.js</td><td>Cross between Primordial Soup and Birthpool. Requires fey_and_more.js</td><td>Alice</td></tr>
<tr><td>spring.js</td><td>Many nature elements, like sakura trees, butterflies, beehives, and more</td><td><a href="https://R74n.com" class="R74nLink">R74n</a></td></tr>
<tr><td>the_ground_og.js</td><td>Simplified and more stable version of the_ground.js</td><td>Alice</td></tr>
@ -361,7 +362,7 @@
<!----><tr><td class="modCat" colspan="3">Fun & Games</td></tr><!---->
<tr><td>10kelements.js</td><td>Customizable amount of randomly generated elements</td><td>nousernamefound</td></tr>
<tr><td>all_around_fillers.js</td><td>Directional Filler variants</td><td>idk73248</td></tr>
<tr><td>allliquids.js</td><td>Made all elements liquids</td><td>Adora</td></tr>
<tr><td>allliquids.js</td><td>Made all elements liquids</td><td>Orchid</td></tr>
<tr><td>amogus.js</td><td>Small Among Us structure</td><td>Alice</td></tr>
<tr><td>bfdi.js</td><td>Several references to Battle for Dream Island</td><td>Taterbob</td></tr>
<tr><td>citybuilding.js</td><td>Seeds that create miniature buildings and other city-related items</td><td>SquareScreamYT</td></tr>
@ -440,7 +441,7 @@
<tr><td>changeTempReactionParameter.js</td><td>The changeTemp property to modded reactions</td><td>Alice</td></tr>
<tr><td>code_library.js</td><td>Functions and variables common to some other mods</td><td>Alice</td></tr>
<tr><td>controllable_pixel_test.js</td><td>Pixel that can be controlled with the keyboard keys <a href="https://github.com/R74nCom/sandboxels/commit/58dfa9477f2ed7ec9c44b00a35162e7c63bc129c">[More Info]</a> [PC ONLY]</td><td>Alice</td></tr>
<tr><td>customexplosion.js</td><td>Added a custom explosion element and interface for it. check out its <a href="https://sandboxels-mods.the-enchanteden.repl.co/Mods/customexplosion.js">source code</a> for how modders can use it</td><td>Alex</td></tr>
<tr><td>customexplosion.js</td><td>Added a custom explosion element and interface for it.</td><td>Orchid</td></tr>
<tr><td>date_test.js</td><td>K-pop idol birthday testing stuff</td><td>Alice</td></tr>
<tr><td>drawPixels_change_test.js</td><td>Test of altering drawPixels(). Gives burning pixels a red overlay similar to the yellow overlay for charged pixels</td><td>Alice</td></tr>
<tr><td>example_mod.js</td><td>Example mod for new modders</td><td><a href="https://R74n.com" class="R74nLink">R74n</a></td></tr>
@ -455,6 +456,7 @@
<tr><td>modlangs.js</td><td>Customisable property in an element to allow for translations in mods. See the file for instructions on how to implement</td><td>SquareScreamYT</td></tr>
<tr><td>nested_for_reaction_example.js</td><td>Example of using a nested for loop to add reactions. It makes various things kill plants</td><td>Alice</td></tr>
<tr><td>nv7.js</td><td>Giant Nv7 image [Large]</td><td>Nv7</td></tr>
<tr><td>orchidslibrary.js</td><td>Library used by morechemistry.js, plants.js, and datawire.js</td><td>Orchid</td></tr>
<tr><td>place_all_elements.js</td><td>Experimental function that places every pixel</td><td>Alice</td></tr>
<tr><td>randomness_but_tick.js</td><td>Random experimental elements using the tick function feature</td><td>Alice</td></tr>
<tr><td>randomness_but_tool.js</td><td>Random experimental elements using the tool function feature</td><td>Alice</td></tr>
@ -464,7 +466,7 @@
<tr><td>structure_test.js</td><td>Test for implementing structures into Sandboxels</td><td>Alice</td></tr>
<tr><td>test.js</td><td>Test that adds mayo :)</td><td><a href="https://R74n.com" class="R74nLink">R74n</a></td></tr>
<tr><td>tool_pixel_behavior.js</td><td>Gives unique behaviors to tools if placed with cheats</td><td>Alice</td></tr>
<tr><td>worldgenlibrary.js</td><td>World generation library</td><td>Adora</td></tr>
<tr><td>worldgenlibrary.js</td><td>World generation library</td><td>Orchid</td></tr>
<tr><td>worldgen_test.js</td><td>Element that generates a save with a grass layer, dirt layer, rock layer, and a pond</td><td>Alice</td></tr>
<!----><tr><td class="modCat" colspan="3">Broken or Deprecated</td></tr><!---->

244
mods/datawire.js Normal file
View File

@ -0,0 +1,244 @@
/*
Version 1.0.0
*/
if(!enabledMods.includes("/mods/orchidslibrary.js")){
let continueWithout = confirm("Missing dependency for datawire.js: \"orchidslibrary.js\". Continue without? (cancel will add mod and refresh the page)");
if(!continueWithout){
addMod("/mods/orchidslibrary.js", true);
window.location.reload();
}
} else {
elements.data_wire = {
desc: "Transfers data.",
color: ["#6b1502", "#631402", "#6e1400", "#631200"],
properties: {cd: 0, value: null},
tick: function(pixel){
for(let coords of adjacentCoords){
let x = pixel.x+coords[0], y = pixel.y+coords[1];
let p2 = getPixel(x,y);
if(p2 != null){
if(p2.value != null && pixel.cd == 0){
pixel.value = p2.value;
pixel.cd = 15;
};
pixel.value = (pixel.cd == 3) ? null : pixel.value;
if(elements[p2.element].dataInFunc != undefined && pixel.value != null){
elements[p2.element].dataInFunc(p2, pixel.value);
}
}
}
pixel.cd -= (pixel.cd == 0) ? 0 : 1;
},
category: "data",
behavior: behaviors.WALL,
state: "solid",
};
elements.data_input = {
desc: "Holds a data value that can be outputted to any nearby data wire.",
color: ["#e06500", "#f57105", "#f06f05", "#e66c09"],
value: null,
onSelect: function(){
promptInput("Enter data info", (input)=>{elements.data_input.value = input;}, "Data Input", elements.data_input.value);
},
category: "data",
behavior: behaviors.WALL,
state: "solid",
properties: {
value:null,
},
tick: function(pixel){
if(pixel.value == null){
pixel.value = elements.data_input.value;
}
for(let coords of adjacentCoords){
let x = pixel.x+coords[0], y = pixel.y+coords[1];
let p2 = getPixel(x,y);
if(p2 != null && elements[p2.element].dataInFunc != undefined && pixel.value != null){
elements[p2.element].dataInFunc(p2, pixel.value);
}
}
}
}
elements.toggle_data_input = {
desc: "Holds a data value that can be outputted to any nearby data wire when toggled on.",
color: ["#6e3302", "#783905", "#823c03", "#7d3a02"],
value: null,
onSelect: function(){
promptInput("Enter data info", (input)=>{elements.data_input.value = input;}, "Data Input", elements.data_input.value);
},
category: "data",
behavior: behaviors.WALL,
state: "solid",
properties: {
value:null,
val: null,
toggle: false,
clickCd: 0,
},
tick: function(pixel){
if(pixel.val == null){
pixel.val = elements.data_input.value;
}
pixel.value = (pixel.toggle) ? pixel.val : null;
for(let coords of adjacentCoords){
let x = pixel.x+coords[0], y = pixel.y+coords[1];
let p2 = getPixel(x,y);
if(p2 != null && elements[p2.element].dataInFunc != undefined && pixel.value != null){
elements[p2.element].dataInFunc(p2, pixel.value);
}
}
pixel.clickCd -= (pixel.clickCd == 0) ? 0 : 1;
},
onClicked: function(pixel){
if(pixel.clickCd == 0){
pixel.clickCd = 20;
pixel.toggle = !pixel.toggle;
if(pixel.toggle){
pixel.color = noiseify("#edba00", 8);
} else {
pixel.color = noiseify("#6e3302", 8);
}
}
}
}
elements.join = {
desc: "Combines multiple data inputs. Click to reset value.",
color: ["#046e00", "#067a02", "#097006", "#065904", "#056602"],
properties: {val: null, clickCd: 0},
dataInFunc: function(pixel, value){
if(pixel.val != null && !pixel.val.includes(value)){
pixel.val += value;
}
if(pixel.val == null){
pixel.val = value;
}
},
category: "data",
behavior: behaviors.WALL,
state: "solid",
tick: function(pixel){
let p2 = getPixel(pixel.x+1, pixel.y);
if(p2 != null && p2.element == "data_wire"){
p2.value = pixel.val;
}
pixel.clickCd -= (pixel.clickCd == 0) ? 0 : 1;
},
onClicked: function(pixel){
if(pixel.clickCd == 0){
pixel.clickCd = 20;
pixel.val = null;
}
}
}
elements.data_sensor = {
desc: "Scans adjacent pixels for a target property and outputs them, uses \"element\" by default. Click on pixel to change properties.",
color: ["#3d3c28", "#4d4b32", "#4a482f", "#403e28"],
properties: {
value: null,
property: "element",
clickCd: 0,
},
tick: function(pixel){
for(let coords of adjacentCoords){
let x = pixel.x+coords[0], y = pixel.y+coords[1];
let p2 = getPixel(x,y);
if(p2 != null && !["data_wire"].includes(p2.element)){
pixel.value = p2[pixel.property];
}
};
pixel.clickCd -= (pixel.clickCd == 0) ? 0 : 1;
},
onClicked: function(pixel){
let propertyArr = [];
for(let coords of adjacentCoords){
let x = pixel.x+coords[0], y = pixel.y+coords[1];
let p2 = getPixel(x,y);
if(p2 != null){
for(let property in p2){
if(typeof p2[property] != "function" && !propertyArr.includes(property)){
propertyArr.push(property);
}
}
}
};
promptChoose("Choose property this data sensor detects:", propertyArr, (input)=>{pixel.property = input || pixel.property;}, "Property to Detect");
},
category: "data",
behavior: behaviors.WALL,
state: "solid",
}
elements.if = {
desc: "Takes 3 inputs, conditon (1 (true) or 0 (false), x-1), ifTrue (output if true, y-1 (pixel above)), and ifFalse (output if false, y+1 (pixel below)).",
color: ["#00574b", "#005247", "#02594e", "#025c50"],
category: "data",
behavior: behaviors.WALL,
state: "solid",
tick: function(pixel){
let conditionPixel = getPixel(pixel.x-1, pixel.y), truePixel = getPixel(pixel.x, pixel.y-1), falsePixel = getPixel(pixel.x, pixel.y+1);
let condition = (conditionPixel != null &&conditionPixel.value != undefined) ? parseInt(conditionPixel.value) : false;
let trueOut = (truePixel != null && truePixel.value != undefined) ? truePixel.value : 1;
let falseOut = (falsePixel != null && falsePixel.value != undefined) ? falsePixel.value : 0;
let outPixel = getPixel(pixel.x+1, pixel.y);
if(outPixel != null && outPixel.value !== undefined){
outPixel.value = (condition) ? trueOut : falseOut;
}
}
}
elements.equals = {
desc: "Takes 2 inputs, A (y-1 (pixel above)) and B (y+1 (pixel below), returns 1 if they are equal and 0 if they are not.",
color: ["#12ccb3", "#15ebce", "#0bd6bb", "#14dec3"],
category: "data",
behavior: behaviors.WALL,
state: "solid",
tick: function(pixel){
let a = getPixel(pixel.x, pixel.y-1), b = getPixel(pixel.x, pixel.y+1);
if(a != null && b != null){
let aVal = (a.value != undefined) ? a.value : 1;
let bVal = (b.value != undefined) ? b.value : 0;
let outPixel = getPixel(pixel.x+1, pixel.y);
if(outPixel != null && outPixel.value !== undefined){
outPixel.value = (aVal == bVal) ? 1 : 0;
}
}
}
}
elements.prop_setter = {
category: "data",
properties: {
val: null,
},
dataInFunc: function(pixel, value){
pixel.val = value;
},
color: ["#deb150", "#ebba52", "#ebba52", "#e3b44d", "#dbab44"],
state: "solid",
behavior: behaviors.WALL,
tick: function(pixel){
if(pixel.val != null){
let valArr = pixel.val.split(":");
let prop = valArr[0], value = valArr[1];
for(let coords of adjacentCoords){
let x = pixel.x+coords[0], y = pixel.y+coords[1];
let p2 = getPixel(x,y);
if(p2 != null && p2[prop] != undefined && elements[p2.element].category != "data"){
if(prop == "element"){
changePixel(p2, value);
} else if (prop == "x" || prop == "y"){
let x = (prop == "x") ? value : p2.x, y = (prop == "y") ? value : p2.y;
tryMove(p2, parseInt(x), parseInt(y), null, true);
} else {
if(typeof p2[prop] == "number"){
p2[prop] = parseInt(value);
} else if(typeof p2[prop] == "boolean"){
p2[prop] = value.includes("true");
} else if(typeof p2[prop] == "string"){
p2[prop] = value;
};
}
}
}
}
}
};
}

File diff suppressed because it is too large Load Diff

70
mods/orchidslibrary.js Normal file
View File

@ -0,0 +1,70 @@
/*
Version 1.0.0
*/
function noiseify(color, range){
if(color.startsWith("#")){
color = hexToRGB(color);
} else {
color = getRGB(color);
}
let num = Math.round(Math.random()*(range*2))-range;
for(let value in color){
color[value] += num;
}
return `rgb(${color.r},${color.g},${color.b})`;
}
let is2d = (arr)=>{
return arr.some(item => Array.isArray(item));
}
function colorMix(p1, p2, bias = 0.5){
c1 = p1.color;
p1.color = interpolateRgb(getRGB(p1.color), getRGB(p2.color), bias);
p2.color = interpolateRgb(getRGB(c1), getRGB(p2.color), bias);
}
function interpolateRgb(rgb1, rgb2, ratio = 0.5) {
const interpolatedRgb = {
r: Math.round(rgb1.r + (rgb2.r - rgb1.r) * ratio),
g: Math.round(rgb1.g + (rgb2.g - rgb1.g) * ratio),
b: Math.round(rgb1.b + (rgb2.b - rgb1.b) * ratio),
};
return normalize(interpolatedRgb);
}
function getRGB(rgb){
if(rgb.startsWith("rgb(")){
let rgb2 = rgb.replace(")", "").replace("rgb(", "").replace(/,/g, "r").split("r")
return { r: parseInt(rgb2[0]), g: parseInt(rgb2[1]), b: parseInt(rgb2[2]) };
} else {
return hexToRGB(rgb2);
}
}
function pixelToggle(pixel, multi = {r:1,g:1,b:1}){
if(pixel.toggle != undefined){
pixel.toggle = !pixel.toggle;
let rgb;
if(Array.isArray(elements[pixel.element].color)){
let elemColor = elements[pixel.element].color[Math.round(Math.random()*elements[pixel.element].color.length)];
rgb = hexToRGB(elemColor) || getRGB(elemColor);
} else {
let elemColor = elements[pixel.element].color;
rgb = hexToRGB(elemColor) || getRGB(elemColor);
}
let num = 5 - Math.round(Math.random()*10);
if(pixel.toggle){
for(let key in rgb){
rgb[key] += (100*multi[key]);
rgb[key] = Math.round(Math.max(Math.min(rgb[key], 255), 0));
}
pixel.color = `rgb(${rgb.r+num},${rgb.g+num},${rgb.b+num})`;
}
else {
pixel.color = `rgb(${rgb.r+num},${rgb.g+num},${rgb.b+num})`;
}
}
}
function normalize(obj){
return `rgb(${obj.r},${obj.g},${obj.b})`;
}

File diff suppressed because it is too large Load Diff