Merge branch 'R74nCom:main' into main

This commit is contained in:
JustAGenericUsername 2024-06-15 21:46:44 -04:00 committed by GitHub
commit d55c5ad6e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 2070 additions and 84 deletions

View File

@ -16754,7 +16754,7 @@ Cancer, Landmine, Grenade, Smoke Grenade">?</span>
<!-- <p>If you'd like to support us, consider donating on <a href="https://www.paypal.com/donate/?hosted_button_id=GCX4VHQ7SZWTN" target="_blank">PayPal</a> or <a href="https://cash.app/$emojiartist" target="_blank" title="$emojiartist">CashApp</a>, or subscribing on Discord.</p> -->
<p>Business inquiries? Education stories? Help needed? Email us at <a href="mailto:contact@R74n.com?subject=%5BSandboxels%5D">contact@R74n.com</a>!</p>
<p>More links: <a href="https://sandboxels.R74n.com/help" rel="help">Help</a><a href="https://sandboxels.R74n.com/tips">Tips</a><a href="https://sandboxels.R74n.com/mod-list">Mods</a><a href="https://sandboxels.R74n.com/mobile-use">Mobile</a><a href="https://sandboxels.R74n.com/offline-use">Offline</a><a href="https://R74n.com/privacy">Privacy</a></p>
<p>Thanks to: Serioustar, ggod, Midi_png, personman, fnl4y, PitsPower, swagg boi, kaeud, WeiChei, Trent, u2ce</p>
<p>Thanks to: Serioustar, ggod, Midi_png, personman, fnl4y, PitsPower, swagg boi, moss, kaeud, WeiChei, Trent, u2ce</p>
<p style="display:none" id="langCredit">Translation by R74n</p>
<p>Sandboxels is developed by R74n. Check out <a href="https://R74n.com" rel="author" target="_blank">our other projects</a>!</p>
<script>

View File

@ -126,6 +126,7 @@
<tr><td>buildingreplicator.js</td><td>Scans and replicates builds anywhere on the screen, along with some preset submitted builds</td><td>nousernamefound</td></tr>
<tr><td>change.js</td><td>Adds a tool that only replaces existing pixels</td><td>Alice</td></tr>
<tr><td>color_tools.js</td><td>Adds tools that manipulate colors</td><td>Alice</td></tr>
<tr><td>controllable_pixel.js</td><td>Adds a pixel controlled using WASD (keyboard required)</td><td>Jayd</td></tr>
<tr><td>controllable_pixel_test.js</td><td>Adds a pixel that can be controlled with the keyboard keys. <a href="https://github.com/R74nCom/sandboxels/commit/58dfa9477f2ed7ec9c44b00a35162e7c63bc129c">Read the commit description for more info.</a> [PC ONLY]</td><td>Alice</td></tr>
<tr><td>cpt_alt.js</td><td>Adds a more destructive variant of the controllable pixel</td><td>Alice</td></tr>
<tr><td>debugRework.js</td><td>Revamps the Debug tool</td><td>Fioushemastor</td></tr>
@ -220,6 +221,7 @@
<!----><tr><td class="modCat" colspan="3">Weapons</td></tr><!---->
<tr><td>aircrafts.js</td><td>Adds aircraft and aircraft part pixels</td><td>Jayd</td></tr>
<tr><td>c_fighter_jet.js</td><td>Adds a controllable fighter jet, wasd to move, q+wasd to shoot, gvbn for missiles.</td><td>Jayd</td></tr>
<tr><td>icb.js</td><td>Adds various levels of nested cluster bombs</td><td>Alice</td></tr>
<tr><td>life_eater.js</td><td>Adds Warhammer 40,000s Life-Eater Virus and Virus Bombs</td><td>Alice</td></tr>
<tr><td>liquid_void.js</td><td>Adds a liquid variant of Void</td><td>Alice</td></tr>

View File

@ -22,7 +22,7 @@ elements.low_battery= {
],
behaviorOn: [
"XX|SH%10|XX", // shocks (adds charge)
"SH%10|CH:charged_battery%0.05|SH%10",
"SH%10|CH:charged_battery%0.045|SH%10",
"XX|SH%10|XX",
],
colorOn: "#4fb613",
@ -41,7 +41,7 @@ elements.dead_battery= {
],
behaviorOn: [
"XX|XX|XX",
"XX|CH:low_battery%0.05|XX",
"XX|CH:low_battery%0.045|XX",
"XX|XX|XX",
],
colorOn: "#699e19",
@ -93,7 +93,196 @@ elements.radio_wave= {
}
},
category: "energy",
reactions: {electric: {elem1: null, elem2: null, chance: 0.5}},
density: 1,
//charge: 0.5,
conduct: 0.01
conduct: 0.01,
ignore: ["radio_wave"],
};
elements.e_nuke = {
desc: "Works like a nuke but needs power to explode",
color: elements.nuke.color,
hardness: 0.5,
state: "solid",
behavior: behaviors.POWDER,
conduct: 1,
category: "weapons",
behaviorOn: [
"XX|XX|XX",
"XX|XX|XX",
"M2|M1 AND EX:60>plasma,plasma,plasma,plasma,radiation,rad_steam|M2",
],
name: "E-Nuke",
};
elements.drill = {
color: ["#a7ab81","#a3a685", "#9ba252"],
tick: function(pixel) {
for (var i = 0; i < 3; i++) {
var skip = false;
if (!isEmpty(pixel.x,pixel.y+1,true)) {
var p = pixelMap[pixel.x][pixel.y+1];
if (p.element === "drill") { skip = true; }
if (Math.random() < 0.9 && elements[p.element].hardness !== 1) {
deletePixel(p.x,p.y);
}
}
if (!tryMove(pixel,pixel.x,pixel.y+1,["flash","smoke"]) && !skip) {
explodeAt(pixel.x,pixel.y,5,"flash");
var coords = circleCoords(pixel.x,pixel.y,2);
coords.forEach(function(coord){
var x = coord.x;
var y = coord.y;
if (!isEmpty(x,y,true)) {
pixelMap[x][y].temp += 55;
pixelTempCheck(pixelMap[x][y]);
}
})
deletePixel(pixel.x,pixel.y);
return;
}
}
},
category: "weapons",
state: "solid",
density: 100000000,
temp: 55,
hardness: 1,
maxSize: 3,
cooldown: defaultCooldown,
excludeRandom: true,
};
elements.holy_hand_grenade = {
color: elements.gold.color,
behavior: [
"XX|EX:6>god_ray,bless,bless,bless%1|XX",
"XX|XX|XX",
"M2|M1 AND EX:6>god_ray,bless,bless,bless%1|M2",
],
behaviorOn: [
"XX|XX|XX",
"XX|EX:6>god_ray,bless,bless,bless%1|XX",
"XX|XX|XX",
],
category: "weapons",
state: "solid",
density: 1300,
tempHigh: 1455.5,
stateHigh: ["molten_steel", "god_ray"],
excludeRandom: true,
conduct: 1,
cooldown: defaultCooldown,
};
//Fioushemastor (Aparently needlessly complicated. IDK)
elements.timer_input = {
color: "#4d0a03",
behavior: behaviors.WALL,
category: "machines",
insulate: true,
conduct: 1,
noMix: true
}
let TimerDelay = 100
elements.Timer = {
color: "#838cc2",
behavior: behaviors.WALL,
tick: function(pixel){
if (pixelTicks == pixel.start) {
pixel.delay = TimerDelay
}
//ceck all surroundings
for (let offset of adjacentCoords) {
if (isEmpty(pixel.x+offset[0], pixel.y+offset[1])) continue;
if (pixelMap[pixel.x+offset[0]][pixel.y+offset[1]].charge && pixelMap[pixel.x+offset[0]][pixel.y+offset[1]].element == "timer_input") {
let oppositeCoords = {x: pixel.x-offset[0], y: pixel.y-offset[1]}
pixel.timers.push({start: pixelTicks, coords: oppositeCoords, delay: pixel.delay})
}
}
//go through all timers
for (let index in pixel.timers) {
let timer = pixel.timers[index]
if (timer.start == pixelTicks-pixel.delay) {
if (isEmpty(timer.coords.x, timer.coords.y, true)) continue;
pixelMap[timer.coords.x][timer.coords.y].charge = 1
pixel.timers.splice(index, 1)
}
}
},
onSelect: () => {
TimerDelay = prompt("what shall the delay be? (in ticks)", 100)
},
colorOn: "#ffff59",
category: "machines",
tempHigh: 1455.5,
stateHigh: "molten_steel",
conduct: 0,
properties: {
timers: [],
delay: 100
}
};
//ExtraMachines
elements.titanium = {
desc: "Another metal that does not erode nor conduct electricity",
conduct: 0,
color: ["#a1ada5","#ebf5ee","#bac2bc","#848a86","#505251"],
tempHigh:3000,
stateHigh: "molten_titanium",
category: "solids",
state: "soild",
hardness: 1,
density: 792,
behavior: behaviors.WALL,
};
elements.molten_titanium = {
desc: "Melted version of titanium",
temp : 3000,
conduct: 0,
color: ["#d16e04","#FFCC99","#FF6600","#FF7F50","#DC143C","#800020"],
tempLow:2999,
stateLow: "titanium",
category: "states",
state: "soild",
density: 792,
behavior: behaviors.MOLTEN,
};
textures.Reniforced_Titanuim = {
REINFORCEDTITANIUM: [
"GiGgggGiGGg",
"gggGGGGgggg",
"iiiiiiiiiii",
"GgGGggggGGg",
"GggGGgggGGg",
"igGGGgggggi",
"GggggggGGGG",
"GggGGgggggg",
"Ggggggggggg",
"ggggggGGggg",
"Ggggggggggg",
"iiiiiiiiiii",],
};
elements.Reniforced_Titanuim = {
color: "#787878",
colorPattern: textures.Reniforced_Titanuim.REINFORCEDTITANIUM,
colorKey: {
"g": "#787878",
"G": "#606060",
"i": "#332f2f"},
behavior: behaviors.WALL,
tempHigh: 4000,
stateHigh : "molten_titanium",
category: "solids",
state: "solid",
density: 5000,
hardness:1,
noMix: true
};

169
mods/IreThings.js Normal file
View File

@ -0,0 +1,169 @@
elements.charged_battery= {
color: "#9c6c25",
behavior: [
"XX|SH%50|XX", // shocks (adds charge)
"SH%50|CH:low_battery%0.05|SH%50",
"XX|SH%50|XX",
],
colorOn: "#00ff00",
category: "machines",
tempHigh: 1455.5,
stateHigh: ["molten_steel","explosion","acid_gas"],
charge: 0.5,
conduct: 1,
};
elements.low_battery= {
color: "#9c6c25",
behavior: [
"XX|SH%10|XX", // shocks (adds charge)
"SH%10|CH:dead_battery%0.05|SH%10",
"XX|SH%10|XX",
],
behaviorOn: [
"XX|SH%10|XX", // shocks (adds charge)
"SH%10|CH:charged_battery%0.045|SH%10",
"XX|SH%10|XX",
],
colorOn: "#4fb613",
category: "machines",
tempHigh: 1455.5,
stateHigh: ["molten_steel","explosion","acid_gas"],
charge: 0.5,
conduct: 0.75,
};
elements.dead_battery= {
color: "#9c6c25",
behavior: [
"XX|XX|XX",
"XX|XX|XX",
"XX|XX|XX",
],
behaviorOn: [
"XX|XX|XX",
"XX|CH:low_battery%0.045|XX",
"XX|XX|XX",
],
colorOn: "#699e19",
category: "machines",
tempHigh: 1455.5,
stateHigh: ["molten_steel","explosion","acid_gas"],
charge: 0.5,
conduct: 0.5,
};
elements.radio_broadcaster= {
color: "#78784c",
behavior: behaviors.WALL,
behaviorOn: [
"XX|SH AND CR:radio_wave AND CR:radio_wave|XX",
"SH AND CR:radio_wave AND CR:radio_wave|XX|SH AND CR:radio_wave AND CR:radio_wave",
"XX|SH AND CR:radio_wave AND CR:radio_wave|XX",
],
colorOn: "#ffff59",
category: "machines",
tempHigh: 1455.5,
stateHigh: ["molten_steel","explosion","acid_gas"],
conduct: 1
};
elements.radio_receiver= {
color: "#78784c",
behavior: behaviors.WALL,
reactions: {radio_wave: {elem2: "electric", chance: 0.75}},
colorOn: "#ffff59",
category: "machines",
tempHigh: 1455.5,
stateHigh: ["molten_steel","explosion","acid_gas"],
conduct: 1
};
elements.radio_wave= {
color: ["#000000"],
behavior: behaviors.BOUNCY,
behaviorOn: [
["XX","CL","XX"],
["CL","DL%5","CL"],
["XX","CL","XX"]
]
,
colorOn: "#000000",
tick: function(pixel){
if (currentElement == "radio_wave"){
pixel.color = "rgb(15, 15, 15)";
} else {
pixel.color = "rgba(0, 0, 0, -1)";
}
},
category: "energy",
reactions: {electric: {elem1: null, elem2: null, chance: 0.5}},
density: 1,
//charge: 0.5,
conduct: 0.01
};
elements.e_nuke = {
desc: "Works like the nuke but needs power to explode",
color: "#534636",
hardness: elements.nuke.hardness,
state: "solid",
behavior: [
"XX|XX|XX",
"XX|XX|XX",
"M2|M1|M2",
],
conduct: 1,
category: "weapons",
behaviorOn:[
"XX|XX|XX",
"XX|XX|XX",
"M2|M1 AND EX:60>plasma,plasma,plasma,plasma,radiation,rad_steam|M2",
],
};
elements.10_timer= {
color: ["#000000"],
behavior: behaviors.WALL,
colorOn: "#000000",
conduct: 0,
category: "machines",
properties: {
wait: 15,
waitReduce: false,
},
tick: function(pixel){
if (pixel.waitReduce){pixel.wait -= 1}
if (pixel.wait == 0){
pixel.elementsSeen = {}
}
for (var i = 0; i < adjacentCoords.length; i++) {
var coord = adjacentCoords[i];
var x = pixel.x+coord[0];
var y = pixel.y+coord[1];
if (!isEmpty(x,y, true)){
if (!pixel.waitReduce){
pixel.waitReduce = true
},
if (pixel.wait == 0){
if (!pixel.elementsSeen[pixelMap[x][y].element] && pixelMap[x][y].element != "healing_serum"){
pixel.elementsSeen[pixelMap[x][y].element] = 1
} else if (pixelMap[x][y].element != "healing_serum") {
pixel.elementsSeen[pixelMap[x][y].element] += 1
}
}
}
if (pixel.wait == 0){
if (Object.keys(pixel.elementsSeen).length == 0){
deletePixel(pixel.x, pixel.y)
return;
} else{
changePixel(pixel, Object.keys(pixel.elementsSeen).reduce((a, b) => pixel.elementsSeen[a] > pixel.elementsSeen[b] ? a : b))
}
}
}
}
}
elements.gasoline_engine = {
color: "#6d5f5d",
behavior: behaviors.WALL,
state: "solid",
density: 1000,
category: "testing",
properties: {
timer: 10
},

View File

@ -145,3 +145,36 @@ elements.lamb = {
density: 1450,
conduct: 0.2
};
converter1Var = 0;
converter2Var = 0;
elements.loom = {
color: "#296127",
behavior: behaviors.WALL,
category: "machines",
tick: function(pixel) {
if (pixel.start === pixelTicks){
pixel.contype = converter2Var;
pixel.specialturn = converter1Var;
}
for (var i = 0; i < squareCoords.length; i++) {
var coord = squareCoords[i];
var x = pixel.x+coord[0];
var y = pixel.y+coord[1];
if (!isEmpty(x,y, true)) {
var otherPixel = pixelMap[x][y];
if ((otherPixel.element == pixel.specialturn || pixel.specialturn == "all") && !elements.converter.ignore.includes(otherPixel.element)){
changePixel(otherPixel, pixel.contype)
}
}
}
},
onSelect: function() {
var answer5 = prompt("Please input what type of element should be converted. Write \"all\" to include everything.",(converter1Var||undefined));
if (!answer5) { return }
converter1Var = answer5;
var answer6 = prompt("Please input what it should turn into.",(converter2Var||undefined));
if (!answer6) { return }
converter2Var = answer6;
},
movable: false,
},

View File

@ -1439,11 +1439,11 @@ try {
};
if (elements[pixel.element].breakIntoColor) {
var oldelement = pixel.element;
changePixel(pixel,result);
changePixel(pixel,result,changeTemp);
pixel.color = pixelColorPick(pixel, elements[oldelement].breakIntoColor);
}
else {
changePixel(pixel,result);
changePixel(pixel,result,changeTemp);
}
}
defaultHardness = 0.3;

367
mods/alchem.js Normal file
View File

@ -0,0 +1,367 @@
initialElements = ["water","dirt","fire","oxygen"];
function findReachable(elems) {
let redo = true;
for(let i = 0; i < elems.length; i++)
{
if(redo)
{
i = 0;
}
redo = false;
let e1 = elems[i];
if(e1 === "mushroom_gill") {
redo = redo || addElement(elems, "mushroom_cap");
}
if(e1 === "thorium" && elems.includes("neutron")) {
redo = redo || addElement(elems, "radium");
}
if(elements[e1].burnInto) {
redo = redo || addElement(elems, elements[e1].burnInto);
}
if(elements[e1].stateHigh) {
redo = redo || addElement(elems, elements[e1].stateHigh);
}
if(elements[e1].stateLow) {
redo = redo || addElement(elems, elements[e1].stateLow);
}
if(elements[e1].breakInto) {
redo = redo || addElement(elems, elements[e1].breakInto);
}
if(elements[e1].extraTempLow) {
for(let i in elements[e1].extraTempLow) {
redo = redo || addElement(elems, elements[e1].extraTempLow[i]);
}
}
if(elements[e1].behavior && elements[e1].behavior instanceof Array) {
let behavior = elements[e1].behavior;
for(let i = 0; i < behavior.length; i++)
{
for(let j = 0; j < behavior[i].length; j++)
{
let b0 = behavior[i][j].split(" AND ");
for (var k = 0; k < b0.length; k++) {
var b = b0[k];
// remove everything after %
b = b.split("%")[0];
if (b.indexOf(":") != -1) {
var arg = b.split(":")[1];
}
else { var arg = undefined }
var b = b.split(":")[0];
if (b == "CR" || b == "CH" || b == "LB" || b == "L1" || b == "L2" || b == "C2") {
if (!arg) { arg = "[???]" }
else if (arg.indexOf(">") != -1) { arg = arg.split(">")[1]; }
redo = redo || addElement(elems, arg.split(","));
}
}
}
}
}
for(let j in elements[e1].reactions)
{
if(elems.includes(j)) {
if(elements[e1].reactions[j].elem1) {
redo = redo || addElement(elems, elements[e1].reactions[j].elem1);
}
if(elements[e1].reactions[j].elem2) {
redo = redo || addElement(elems, elements[e1].reactions[j].elem2);
}
}
}
}
return elems;
}
function addElement(list, elem) {
if(elem instanceof Array)
{
let result = false;
for(let i = 0; i < elem.length; i++)
{
result = result || addElement(list,elem[i]);
}
return result;
}
if(elem && !list.includes(elem)) {
list.push(elem);
return true;
}
}
let chemMod = document.querySelector("[src=\"mods/chem.js\"]");
// unhide oxygen (air), dirt (earth), fire, and water
function loadAlchem() {
if(!elements.hematite) {
elements.hematite = {
color: ["#e0472f","#bf2a2a","#913920"],
behavior: behaviors.POWDER,
category: "alchemy mod",
density: 5250,
state: "solid",
tempHigh: 1539,
hidden: true
};
elements.molten_hematite = {
reactions: {
"charcoal": { elem1: ["molten_iron","molten_iron","molten_iron","molten_iron","molten_nickel"], elem2: "carbon_dioxide"},
},
};
elements.molten_slag.ignore.push("hematite");
}
elements.molten_pyrite = {
reactions: {
"oxygen": { elem1: "iron", elem2: "sulfur_dioxide"},
},
};
elements.molten_slag.ignore.push("pyrite");
if(!elements.chalcopyrite) {
elements.chalcopyrite = {
color: ["#e8d7cb","#cdc0af","#726153","#8f775e","#bfaea0",],
behavior: behaviors.WALL,
category: "alchemy mod",
density: 4200,
state: "solid",
tempHigh: 950,
hidden: true
};
elements.molten_chalcopyrite = {
reactions: {
"charcoal": { elem1: "molten_copper", elem2: ["molten_slag","molten_slag","sulfur_dioxide","sulfur_dioxide","sulfur_dioxide","molten_iron"]},
},
};
elements.molten_slag.ignore.push("chalcopyrite");
}
if(!elements.sphalerite) {
elements.sphalerite = {
color: ["#7a7a7a","#5c5c5c","#3d3d3d","#363636","#e0e0e0",],
behavior: behaviors.WALL,
category: "alchemy mod",
density: 4090,
state: "solid",
tempHigh: 1850,
hidden: true
};
elements.molten_sphalerite = {
reactions: {
"charcoal": { elem1: "molten_zinc", elem2: ["sulfur_dioxide","sulfur_dioxide","sulfur_dioxide","sulfur_dioxide","sulfur_dioxide","gallium_gas"]},
},
};
elements.molten_slag.ignore.push("sphalerite");
}
if(!elements.cassiterite) {
elements.cassiterite = {
color: ["#5e5b5b","#705a4d","#826f6f","#333030","#e3d8d1"],
behavior: behaviors.WALL,
category: "alchemy mod",
density: 6950,
state: "solid",
tempHigh: 1630,
hidden: true
};
elements.molten_cassiterite = {
reactions: {
"charcoal": { elem1: "molten_tin", elem2: "carbon_dioxide"},
},
};
elements.molten_slag.ignore.push("cassiterite");
}
if(!elements.galena) {
elements.galena = {
color: ["#e6e6e6","#bdbdbd","#7a7a7a","#737373"],
behavior: behaviors.WALL,
category: "alchemy mod",
density: 7600,
state: "solid",
tempHigh: 1113,
hidden: true
};
elements.molten_galena = {
reactions: {
"charcoal": { elem1: "molten_lead", elem2: "sulfur_dioxide"},
},
};
elements.molten_slag.ignore.push("galena");
}
let ores = Array(5).fill("molten_hematite")
.concat(Array(5).fill("molten_pyrite"))
.concat(Array(5).fill("molten_chalcopyrite"))
.concat(Array(3).fill("molten_cassiterite"))
.concat(Array(5).fill("molten_sphalerite"))
.concat(Array(3).fill("molten_galena"))
.concat(Array(2).fill("molten_rutile"))
.concat(Array(5).fill("molten_bauxite"))
.concat(Array(2).fill("molten_silver"))
.concat(Array(1).fill("molten_gold"))
.concat(Array(3).fill("molten_fluorite"))
.concat(Array(3).fill("molten_uraninite"))
elements.molten_slag.ignore.push("rutile");
elements.molten_slag.ignore.push("bauxite");
elements.molten_slag.ignore.push("silver");
elements.molten_slag.ignore.push("gold");
elements.seltzer.reactions["electric"] =
{ elem1: "water", elem2:"methane"};
elements.carbon_dioxide.reactions["electric"] =
{ elem1:"methane"};
elements.magma.reactions["magma"] =
{ elem2:ores, tempMin:2500, tempMax:3000, chance:0.0001};
if (!settings.alchemyUnlocked) {
settings.alchemyUnlocked = {
"oxygen": true,
"dirt": true,
"fire": true,
"water": true,
};
}
if (settings.unlocked.alchemymod) {
for (var element in settings.unlocked) {
if (settings.unlocked[element]) {
settings.alchemyUnlocked[element] = true
}
}
}
// loop through the elements object
if (elements.explosion) {
elements.explosion.category = "tools";
}
if (elements.room_temp) {
elements.room_temp.category = "tools";
}
if (elements.cook) {
elements.cook.category = "tools";
}
if (elements.incinerate) {
elements.incinerate.category = "tools";
}
for (var element in elements) {
if (elements[element].category === "tools") {
settings.alchemyUnlocked[element] = true;
}
if (settings.alchemyUnlocked[element]) {
elements[element].hidden = false;
if (elements[element].category !== "tools") { elements[element].category = "alchemy mod"; }
}
else if (elements[element].category !== "tools") {
// give the element the hidden attribute true
elements[element].hidden = true;
// set its category to "alchemy mod"
elements[element].category = "alchemy mod";
}
}
// set the unhide setting to Unlock as Discovered (2)
settings.unhide = 2;
runAfterLoad(function(){
checkUnlock = function(element) {
if (elements[element] && elements[element].hidden && !settings.alchemyUnlocked[element]) {
settings.alchemyUnlocked[element] = true;
if (settings.unhide === 2) {
createElementButton(element)
var categoryButton = document.querySelector(".categoryButton[current='true']");
var currentCategory = categoryButton.getAttribute("category");
if (currentCategory !== elements[element].category) {
document.getElementById("categoryButton-"+elements[element].category).classList.add("notify");
}
// add notify to the elementButton of the element
document.getElementById("elementButton-"+element).classList.add("notify");
}
saveSettings();
}
}
})
runAfterAutogen(function(){
for (var element in elements) {
if (elements[element].category === "states") {
elements[element].category = "alchemy mod"
}
}
})
window.addEventListener("load",function(){
for (var element in elements) {
if (elements[element].hidden && document.getElementById("elementButton-"+element)) {
document.getElementById("elementButton-"+element).remove()
}
}
})
/*runAfterAutogen(function(){
let reachable = findReachable(initialElements);
console.log(reachable.join(","));
let string = "";
for(let i in elements)
{
if(!reachable.includes(i))
{
if(string === "")
{
string = i;
}
else
{
string += "," + i;
}
}
}
console.log(string);
string = "";
for(let i = 0; i < reachable.length; i++)
{
if(!settings.alchemyUnlocked[reachable[i]])
{
if(string === "")
{
string = reachable[i];
}
else
{
string += "," + reachable[i];
}
}
}
console.log(string);
string = "";
for(let i in settings.alchemyUnlocked)
{
if(!reachable.includes(i) && settings.alchemyUnlocked[i] && elements[i].category !== "tools")
{
if(string === "")
{
string = i;
}
else
{
string += "," + i;
}
}
}
console.log(string);
});*/
}
if(chemMod) {
chemMod.addEventListener("load",loadAlchem);
} else {
loadAlchem();
}

449
mods/c_fighter_jet.js Normal file
View File

@ -0,0 +1,449 @@
document.onkeydown = function(ki)/*keyboard_input*/ {
//a
if (ki.keyCode == 65) {
KA = true;
}
//d
if (ki.keyCode == 68) {
KD = true;
}
//w
if (ki.keyCode == 87) {
KW = true;
}
//s
if (ki.keyCode == 83) {
KS = true;
}
if (ki.keyCode == 86) {
KJ = true;
}
if (ki.keyCode == 78) {
KL = true;
}
if (ki.keyCode == 71) {
KI = true;
}
if (ki.keyCode == 66) {
KK = true;
}
if (ki.keyCode == 81) {
KQ = true;
}
if (ki.keyCode == 90) {
ammo = 300;
missile = 20;
}
}
document.onkeyup = function(i2)/*input 2*/ {
//a
if (i2.keyCode == 65) {
KA = false;
ul = false;
dl = false;
}
//d
if (i2.keyCode == 68) {
KD = false;
ur = false;
dr = false;
}
//w
if (i2.keyCode == 87) {
KW = false;
ul = false;
ur = false;
}
//s
if (i2.keyCode == 83) {
KS = false;
dl = false;
dr = false;
}
if (i2.keyCode == 86) {
KJ = false;
}
if (i2.keyCode == 78) {
KL = false;
}
if (i2.keyCode == 71) {
KI = false;
}
if (i2.keyCode == 66) {
KK = false;
}
if (i2.keyCode == 81) {
KQ = false;
}
}
var KA = false;
var KD = false;
var KW = false;
var KS = false;
var KJ = false;
var KL = false;
var KI = false;
var KK = false;
var KQ = false;
var vX = 2;
var vY = 2;
var ul = false;
var ur = false;
var dl = false;
var dr = false;
var ammo = 300;
var missile = 20;
elements.cfj = {
name: "c_fighter_jet",
tick: function(pixel) {
logMessage("|");
logMessage("|[Callsign: Box 1]");
logMessage("|[Codename: 'Player]'");
logMessage("|");
logMessage("|[Operation: 'Sandbox']");
logMessage("|['Box Squadron']");
logMessage("|");
logMessage("|[Ammo:" + ammo +"]");
logMessage("|[Missiles:" + missile +"]");
logMessage("|");
if (KA === true) {
tryMove (pixel,pixel.x-vX,pixel.y)
}
if (KD === true) {
tryMove (pixel,pixel.x+vX,pixel.y)
}
if (KW === true) {
tryMove (pixel,pixel.x,pixel.y-vY)
}
if (KS === true) {
tryMove (pixel,pixel.x,pixel.y+vY)
}
if (KJ === true && missile > 0) {
createPixel("cfj_missile_left",pixel.x-1,pixel.y);
missile--;
}
if (KL === true && missile > 0) {
createPixel("cfj_missile_right",pixel.x+1,pixel.y);
missile--;
}
if (KI === true && missile > 0) {
createPixel("cfj_missile_up",pixel.x,pixel.y-1);
missile--;
}
if (KK === true && missile > 0) {
createPixel("cfj_missile_down",pixel.x,pixel.y+1);
missile--;
}
if (KQ === true) {
if (KA === true && dl === false && ul === false && ammo > 0) {
createPixel("cfj_b_l",pixel.x-4,pixel.y);
ammo--;
}
if (KD === true && dr === false && ur === false && ammo > 0) {
createPixel("cfj_b_r",pixel.x+4,pixel.y);
ammo--;
}
if (KW === true && ul === false && ur === false && ammo > 0) {
createPixel("cfj_b_u",pixel.x,pixel.y-4);
ammo--;
}
if (KS === true && dl === false && dr === false && ammo > 0) {
createPixel("cfj_b_d",pixel.x,pixel.y+4);
ammo--;
}
if (KA === true && KW === true && ammo > 0) {
createPixel("cfj_b_ul",pixel.x-4,pixel.y-4);
ul = true;
ammo--;
}
if (KD === true && KW === true && ammo > 0) {
createPixel("cfj_b_ur",pixel.x+4,pixel.y-4);
ur = true;
ammo--;
}
if (KA === true && KS === true && ammo > 0) {
createPixel("cfj_b_dl",pixel.x-4,pixel.y-4);
dl = true;
ammo--;
}
if (KD === true && KS === true && ammo > 0) {
createPixel("cfj_b_dr",pixel.x+4,pixel.y+4);
dr = true;
ammo--;
}
}
},
category: "cfj",
states:"solid",
color:"#FFFFFF",
},
elements.cfj_missile_left = {
color: "#524c41",
category: "cfj",
state: "solid",
behavior: [
"XX|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|XX",
"EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel",
"EX:20>missile_shrapnel|EX:20>missile_shrapnel|M2 AND EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel",
"EX:20>missile_shrapnel|EX:20>missile_shrapnel|M1|XX|EX:20>missile_shrapnel|CR:smoke AND EX:20>missile_shrapnel|EX:20>missile_shrapnel",
"EX:20>missile_shrapnel|EX:20>missile_shrapnel|M2 AND EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel",
"EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel",
"XX|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|XX",
],
tick: function(pixel) {
for (var i=0; i<3; i++) {
if (!tryMove(pixel, pixel.x-1, pixel.y)) {
if (!isEmpty(pixel.x-1, pixel.y,true)) {
}
}
}
},
density: 1300,
excludeRandom: true,
cooldown: defaultCooldown,
ignore: "cfj",
},
elements.cfj_missile_right = {
color: "#524c41",
category: "cfj",
state: "solid",
behavior: [
"XX|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|XX",
"EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel",
"EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|M2 AND EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel",
"EX:20>missile_shrapnel|CR:smoke AND EX:20>missile_shrapnel|EX:20>missile_shrapnel|XX|M1|EX:20>missile_shrapnel|EX:20>missile_shrapnel",
"EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|M2 AND EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel",
"EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel",
"XX|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|XX",
],
tick: function(pixel) {
for (var i=0; i<3; i++) {
if (!tryMove(pixel, pixel.x+1, pixel.y)) {
if (!isEmpty(pixel.x+1, pixel.y,true)) {
}
}
}
},
density: 1300,
excludeRandom: true,
cooldown: defaultCooldown,
ignore: "cfj",
},
elements.cfj_missile_up = {
color: "#524c41",
category: "cfj",
state: "solid",
behavior: [
"XX|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|XX",
"EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel",
"EX:20>missile_shrapnel|EX:20>missile_shrapnel|M2 AND EX:20>missile_shrapnel|M1 AND EX:20>missile_shrapnel|M2 AND EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel",
"EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|XX|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel",
"EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel",
"EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|CR:smoke AND EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel",
"XX|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|XX",
],
tick: function(pixel) {
for (var i=0; i<3; i++) {
if (!tryMove(pixel, pixel.x, pixel.y-1)) {
if (!isEmpty(pixel.x, pixel.y-1,true)) {
}
}
}
},
density: 1300,
excludeRandom: true,
cooldown: defaultCooldown,
ignore: "cfj",
},
elements.cfj_missile_down = {
color: "#524c41",
category: "cfj",
state: "solid",
behavior: [
"XX|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|XX",
"EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|CR:smoke AND EX:20>missile_shrapnel|M2 AND EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel",
"EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel",
"EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|XX||EX:20>missile_shrapnel|EX:20>missile_shrapnel",
"EX:20>missile_shrapnel|EX:20>missile_shrapnel|M2 AND EX:20>missile_shrapnel|M1 AND EX:20>missile_shrapnel|M2 AND EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel",
"EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel",
"XX|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|EX:20>missile_shrapnel|XX",
],
tick: function(pixel) {
for (var i=0; i<3; i++) {
if (!tryMove(pixel, pixel.x, pixel.y+1)) {
if (!isEmpty(pixel.x, pixel.y+1,true)) {
}
}
}
},
density: 1300,
excludeRandom: true,
cooldown: defaultCooldown,
ignore: "cfj",
},
elements.missile_shrapnel = {
color: "#71797E",
behavior: [
"XX|XX|XX",
"XX|EX:5 %20|XX",
"M2%20|M1%20|M2%20",
],
burn: 90,
burnTime: 100,
density: 2000,
conduct: 1,
state: "solid",
category: "ammunition"
},
elements.cfj_b_l = {
color: "#4c4e42",
behavior: [
"DB|DB|DB",
"DB|XX|DB",
"DB|DB|DB",
],
tick: function(pixel) {
for (var i=0; i<3; i++) {
if (!tryMove(pixel, pixel.x-3, pixel.y)) {
deletePixel(pixel.x,pixel.y)
}
}
},
category: "cfj",
state: "solid",
insulate: true,
ignore: "cfj",
},
elements.cfj_b_r = {
color: "#4c4e42",
behavior: [
"DB|DB|DB",
"DB|XX|DB",
"DB|DB|DB",
],
tick: function(pixel) {
for (var i=0; i<3; i++) {
if (!tryMove(pixel, pixel.x+3, pixel.y)) {
deletePixel(pixel.x,pixel.y)
}
}
},
category: "cfj",
state: "solid",
insulate: true,
ignore: "cfj",
},
elements.cfj_b_u = {
color: "#4c4e42",
behavior: [
"DB|DB|DB",
"DB|XX|DB",
"DB|DB|DB",
],
tick: function(pixel) {
for (var i=0; i<3; i++) {
if (!tryMove(pixel, pixel.x, pixel.y-3)) {
deletePixel(pixel.x,pixel.y)
}
}
},
category: "cfj",
state: "solid",
insulate: true,
ignore: "cfj",
},
elements.cfj_b_d = {
color: "#4c4e42",
behavior: [
"DB|DB|DB",
"DB|XX|DB",
"DB|DB|DB",
],
tick: function(pixel) {
for (var i=0; i<3; i++) {
if (!tryMove(pixel, pixel.x, pixel.y+3)) {
deletePixel(pixel.x,pixel.y)
}
}
},
category: "cfj",
state: "solid",
insulate: true,
ignore: "cfj",
},
elements.cfj_b_ul = {
color: "#4c4e42",
behavior: [
"DB|DB|DB",
"DB|XX|DB",
"DB|DB|DB",
],
tick: function(pixel) {
for (var i=0; i<3; i++) {
if (!tryMove(pixel, pixel.x-3, pixel.y-3)) {
deletePixel(pixel.x,pixel.y)
}
}
},
category: "cfj",
state: "solid",
insulate: true,
ignore: "cfj",
},
elements.cfj_b_dl = {
color: "#4c4e42",
behavior: [
"DB|DB|DB",
"DB|XX|DB",
"DB|DB|DB",
],
tick: function(pixel) {
for (var i=0; i<3; i++) {
if (!tryMove(pixel, pixel.x-3, pixel.y+3)) {
deletePixel(pixel.x,pixel.y)
}
}
},
category: "cfj",
state: "solid",
insulate: true,
ignore: "cfj",
},
elements.cfj_b_ur = {
color: "#4c4e42",
behavior: [
"DB|DB|DB",
"DB|XX|DB",
"DB|DB|DB",
],
tick: function(pixel) {
for (var i=0; i<3; i++) {
if (!tryMove(pixel, pixel.x+3, pixel.y-3)) {
deletePixel(pixel.x,pixel.y)
}
}
},
category: "cfj",
state: "solid",
insulate: true,
ignore: "cfj",
},
elements.cfj_b_dr = {
color: "#4c4e42",
behavior: [
"DB|DB|DB",
"DB|XX|DB",
"DB|DB|DB",
],
tick: function(pixel) {
for (var i=0; i<3; i++) {
if (!tryMove(pixel, pixel.x+3, pixel.y+3)) {
deletePixel(pixel.x,pixel.y)
}
}
},
category: "cfj",
state: "solid",
insulate: true,
ignore: "cfj",
}

View File

@ -1,7 +1,15 @@
function toObject(color)
{
color = color.match(/\d+/g);
return color;
return {"r":color[0],"g":color[1],"b":color[2]};
}
function RGBToHex2(rgb) {
var r = Math.min(255,parseInt(rgb.r));
var g = Math.min(255,parseInt(rgb.g));
var b = Math.min(255,parseInt(rgb.b));
return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
}
function react(elem1,elem2,product1,product2,temp)
@ -18,6 +26,10 @@ function acidReact(elem1,elem2,product1,product2,temp = 0)
{
elements[elem1].ignore.push(...product1);
}
else
{
elements[elem1].ignore.push(product1);
}
}
if(product2 !== null)
{
@ -25,6 +37,10 @@ function acidReact(elem1,elem2,product1,product2,temp = 0)
{
elements[elem1].ignore.push(...product2);
}
else
{
elements[elem1].ignore.push(product2);
}
}
elements[elem1].ignore.push(elem2);
}
@ -245,6 +261,14 @@ elements.hydrofluoric_acid_gas = {
category:"gases",
};
runAfterLoad(function() {
reactList("hydrofluoric_acid", eLists.WATER, { "elem1":null, "elem2":"dirty_water" });
reactList("hydrofluoric_acid_gas", eLists.WATER, { "elem1":null, "elem2":"dirty_water" });
delete elements.hydrofluoric_acid.reactions["dirty_water"];
delete elements.hydrofluoric_acid_gas.reactions["dirty_water"];
});
elements.hydrogen_fluoride = {
color: "#f2f28d",
behavior: behaviors.GAS,
@ -573,6 +597,12 @@ function createAcid(name,reactions, gasReactions, color, categoryhidden, categor
if(compound == "acid") {
eListAddIon("HYDROGEN", [name, name+"_gas"], compound);
}
runAfterLoad(function() {
reactList(name, eLists.WATER, { "elem1":null, "elem2":"dirty_water" });
reactList(name+"_gas", eLists.WATER, { "elem1":null, "elem2":"dirty_water" });
delete elements[name].reactions["dirty_water"];
delete elements[name+"_gas"].reactions["dirty_water"];
});
}
function eListAddIon(listName, itemList, compoundType = "default", priority = 0)
@ -1140,6 +1170,8 @@ elements.hydrogen_sulfide = {
runAfterLoad(function() {
reactList("hydrogen_sulfide", eLists.WATER, { "elem1":null, "elem2":"dirty_water" });
delete elements.hydrogen_sulfide.reactions["dirty_water"];
delete elements.hydrogen_sulfide.reactions["iron_dichloride_solution"];
});
acidIgnore(["sulfur_dioxide","liquid_sulfur_dioxide","sulfur_dioxide_ice"]);
@ -1169,6 +1201,9 @@ elements.sulfuric_acid_gas.ignore.push("charcoal");
runAfterLoad(function() {
reactList("sulfuric_acid", eLists.WATER, { "elem2":"dirty_water"});
reactList("sulfuric_acid_gas", eLists.WATER, { "elem2":"dirty_water"});
delete elements.sulfuric_acid.reactions["dirty_water"];
delete elements.sulfuric_acid_gas.reactions["dirty_water"];
});
elements.sulfuric_acid.reactions["grape"] = { "elem1": "charcoal", "elem2": "steam", "temp2": 200};
elements.sulfuric_acid.reactions["juice"] = { "elem1": "charcoal", "elem2": "steam", "temp2": 200};
@ -1553,9 +1588,9 @@ elements.titanium_tetrachloride = {
density: 1728,
state: "liquid",
tempHigh: 136.4,
stateHigh: "titanium_tetrachloride_gas",
stateHighName: "titanium_tetrachloride_gas",
tempLow: -24,
stateLow: "solid_titanium_tetrachloride",
stateLowName: "solid_titanium_tetrachloride",
};
eListAddIon("TITANIUMIV","solid_titanium_tetrachloride");
eListAddIon("CHLORIDE","solid_titanium_tetrachloride");
@ -1727,16 +1762,18 @@ elements.molten_astatine = {
tempHigh: 336,
};
elements.astatine_gas = {
behavior: [
"M2|M1 AND CR:radiation%50|M2",
"M1 AND CR:radiation%50|CH:polonium,big_pop%0.1|M1 AND CR:radiation%50",
"M2|M1 AND CR:radiation%50|M2",
behavior: behaviors.GAS,
behavior2: [
["XX","CR:radiation%50","XX"],
["CR:radiation%50","CH:polonium,big_pop%0.1","CR:radiation%50"],
["XX","CR:radiation%50","XX"]
],
reactions: {
"quark_matter": { "elem1":"molten_stable_astatine", "elem2":"quark_matter"}
},
tick: function(pixel) {
pixel.temp += 5;
pixelTick(pixel,elements[pixel.element].behavior2);
}
}
@ -1780,7 +1817,7 @@ elements.polonium = {
elements.molten_polonium = {
color: ["#ace638","#acb838","#ac8a00"],
behavior: [
"XX|CR:fire,CR:radiation%12.5|XX",
"XX|CR:fire AND CR:radiation%12.5|XX",
"M2 AND CR:radiation%10|CH:lead%0.1|M2 AND CR:radiation%10",
"M1|M1|M1",
],
@ -1904,6 +1941,9 @@ eLists.ACIDGAS.push("hydroastatic_acid_gas");
runAfterLoad(function() {
reactList("hydroastatic_acid", eLists.WATER, {"elem2":"dirty_water"});
reactList("hydroastatic_acid_gas", eLists.WATER, {"elem2":"dirty_water"});
delete elements.hydroastatic_acid.reactions["dirty_water"];
delete elements.hydroastatic_acid_gas.reactions["dirty_water"];
});
elements.polonium_dioxide = {
@ -2323,7 +2363,9 @@ elements.silver_bromide = {
if(!isEmpty(k,l,true) && pixelMap[k][l].element === "silver_bromide")
{
if(distance <= 0) {console.log("a");}
pixelMap[k][l].color = pixelColorPick(pixelMap[k][l],blendColors(RGBToHex(toObject(pixelMap[k][l].color)),RGBToHex(toObject(pixelMap[pixel.x+i][pixel.y+j].color)),1/distance));
let rgb = hexToRGB(blendColors(RGBToHex2(toObject(pixelMap[k][l].color)),RGBToHex2(toObject(pixelMap[pixel.x+i][pixel.y+j].color)),10/(10+distance)));
pixelMap[k][l].color = "rgb("+rgb.r+","+rgb.g+","+rgb.b+")";
//pixelMap[k][l].color = pixelColorPick(pixelMap[k][l],blendColors(RGBToHex2(toObject(pixelMap[k][l].color)),RGBToHex2(toObject(pixelMap[pixel.x+i][pixel.y+j].color)),1/distance));
}
}
if(pixelMap[pixel.x+i][pixel.y+j].element === "light" || pixelMap[pixel.x+i][pixel.y+j].element === "laser")
@ -2699,6 +2741,9 @@ eListAddIon("HYDROGEN","hydroiodic_acid_gas");
eListAddIon("IODIDE","hydroiodic_acid_gas");
runAfterLoad(function() {
reactList("hydroiodic_acid", eLists.WATER, { "elem2":"dirty_water"});
reactList("hydroiodic_acid_gas", eLists.WATER, { "elem2":"dirty_water"});
delete elements.hydroiodic_acid.reactions["dirty_water"];
delete elements.hydroiodic_acid_gas.reactions["dirty_water"];
});
@ -3053,11 +3098,10 @@ elements.liquid_boron_trichloride = {
runAfterLoad(function() {
reactList("fluoroboric_acid", eLists.WATER, { "elem2": "dirty_water" });
});
runAfterLoad(function() {
reactList("fluoroboric_acid_gas", eLists.WATER, { "elem2": "dirty_water" });
reactList("fluoroboric_acid", eLists.WATER, { "elem2":"dirty_water"});
reactList("fluoroboric_acid_gas", eLists.WATER, { "elem2":"dirty_water"});
delete elements.fluoroboric_acid.reactions["dirty_water"];
delete elements.fluoroboric_acid_gas.reactions["dirty_water"];
});
createAcid("fluoroboric_acid",{},{},["#3bffdb","#00caaf","#56c4a3"],true,true,100,100,0,1000,1020,1,"TETRAFLUOROBORATE")
@ -3175,7 +3219,7 @@ runAfterLoad(function() {
});
eLists.CAUSTIC.push("sodium_hydride");
elements.sodium_hydride.ignore = defaultAcidIgnore.concat(eLists.CAUSTICIGNORE);
elements.sodium_hydride.ignore = defaultAcidIgnore.concat(eLists.CAUSTICIGNORE).concat(["sodium","molten_sodium","hydrogen"]);
acidIgnore(["sodium_hydride"]);
elements.molten_sodium.reactions.hydrogen = { elem1: "sodium_hydride", elem2: null};
@ -3575,6 +3619,7 @@ elements.depleted_uranium = {
runAfterLoad(function() {
reactList("depleted_uranium", eLists.WATER, { elem2: "dirty_water", chance:0.25 });
delete elements.depleted_uranium.reactions["dirty_water"];
});
@ -3617,10 +3662,12 @@ elements.enriched_uranium = {
runAfterLoad(function() {
reactList("enriched_uranium", eLists.WATER, { elem2: "dirty_water", chance:0.25 });
delete elements.enriched_uranium.reactions["dirty_water"];
});
runAfterLoad(function() {
reactList("uranium", eLists.WATER, { elem2: "dirty_water", chance:0.25 });
delete elements.uranium.reactions["dirty_water"];
});
@ -3677,6 +3724,7 @@ elements.stable_uranium = {
};
runAfterLoad(function() {
reactList("stable_uranium", eLists.WATER, { elem2: "dirty_water", chance:0.25 });
delete elements.stable_uranium.reactions["dirty_water"];
});
elements.uranium.reactions["oxygen"] = { elem1:"uranium_dioxide", elem2: null, chance:0.1};
@ -3813,7 +3861,7 @@ function reduce(element, element2, result) {
"molten_magnesium": { elem1: result, elem2: "magnesium_fluoride"},
"molten_calcium": { elem1: result, elem2: "fluorite"},
"molten_sodium": { elem1: result, elem2: "sodium_fluoride"},
"molten_sodium": { elem1: result, elem2: "potassium_fluoride"},
"molten_potassium": { elem1: result, elem2: "potassium_fluoride"},
});
}
}
@ -4360,9 +4408,9 @@ elements.stable_plutonium = {
runAfterLoad(function() {
reactList("plutonium", eLists.WATER, { elem2: "dirty_water", chance:0.25 });
});
runAfterLoad(function() {
delete elements.plutonium.reactions["dirty_water"];
reactList("stable_plutonium", eLists.WATER, { elem2: "dirty_water", chance:0.25 });
delete elements.stable_plutonium.reactions["dirty_water"];
});
elements.plutonium_dioxide = {
@ -5512,12 +5560,11 @@ if(!elements.caustic_soda.reactions)
{
elements.caustic_soda.reactions = {};
}
elements.caustic_soda.reactions["water"] = { elem1:"sodium_hydroxide", elem2:null };
elements.caustic_soda.reactions["salt_water"] = { elem1:"sodium_hydroxide", elem2:null };
elements.caustic_soda.reactions["sugar_water"] = { elem1:"sodium_hydroxide", elem2:null };
elements.caustic_soda.reactions["dirty_water"] = { elem1:"sodium_hydroxide", elem2:null };
elements.caustic_soda.reactions["seltzer"] = { elem1:"sodium_hydroxide", elem2:null };
elements.caustic_soda.reactions["pool_water"] = { elem1:"sodium_hydroxide", elem2:null };
runAfterLoad(function() {
reactList("caustic_soda", eLists.WATER, { elem1:"sodium_hydroxide", elem2:null });
delete elements.sodium_hydroxide.reactions["sodium_aluminate_solution"];
delete elements.sodium_hydroxide_gas.reactions["sodium_aluminate_solution"];
});
elements.sodium_hydroxide_gas.tempHigh = 150;
elements.sodium_hydroxide_gas.stateHigh = ["caustic_soda","steam"];
@ -5543,13 +5590,9 @@ if(!elements.caustic_potash.reactions)
{
elements.caustic_potash.reactions = {};
}
elements.caustic_potash.reactions["water"] = { elem1:"potassium_hydroxide", elem2:null };
elements.caustic_potash.reactions["salt_water"] = { elem1:"potassium_hydroxide", elem2:null };
elements.caustic_potash.reactions["sugar_water"] = { elem1:"potassium_hydroxide", elem2:null };
elements.caustic_potash.reactions["dirty_water"] = { elem1:"potassium_hydroxide", elem2:null };
elements.caustic_potash.reactions["seltzer"] = { elem1:"potassium_hydroxide", elem2:null };
elements.caustic_potash.reactions["pool_water"] = { elem1:"potassium_hydroxide", elem2:null };
runAfterLoad(function() {
reactList("caustic_potash", eLists.WATER, { elem1:"potassium_hydroxide", elem2:null });
});
elements.potassium_hydroxide_gas.tempHigh = 150;
elements.potassium_hydroxide_gas.stateHigh = ["caustic_potash","steam"];
@ -5564,6 +5607,12 @@ elements.red_mud.reactions.seltzer = {"elem2":"dirty_water" };
elements.red_mud.reactions.pool_water = {"elem2":"dirty_water" };
elements.red_mud.reactions.primordial_soup = {"elem2":"dirty_water" };
runAfterLoad(function() {
reactList("red_mud", eLists.WATER, { elem2: "dirty_water" });
delete elements.red_mud.reactions["dirty_water"];
delete elements.red_mud.reactions["sodium_aluminate_solution"];
});
acidReact("potassium_hydroxide","fertilizer","niter","ammonia",10);
acidReact("potassium_hydroxide_gas","fertilizer","niter","ammonia",10);
@ -5934,10 +5983,10 @@ eListAddIon("BICARBONATE","baking_soda","base");
eListAddIon("SODIUM","baking_soda_solution","base");
eListAddIon("BICARBONATE","baking_soda_solution","base");
elements["baking_soda"].reactions["sodium_hydroxide"] = {elem1: "sodium_carbonate_solution", elem2: "null"};
elements["baking_soda"].reactions["sodium_hydroxide_gas"] = {elem1: "sodium_carbonate_solution", elem2: "null"};
elements["baking_soda_solution"].reactions["sodium_hydroxide"] = {elem1: "sodium_carbonate_solution", elem2: "null"};
elements["baking_soda_solution"].reactions["sodium_hydroxide_gas"] = {elem1: "sodium_carbonate_solution", elem2: "null"};
elements["baking_soda"].reactions["sodium_hydroxide"] = {elem1: "sodium_carbonate_solution", elem2: null};
elements["baking_soda"].reactions["sodium_hydroxide_gas"] = {elem1: "sodium_carbonate_solution", elem2: null};
elements["baking_soda_solution"].reactions["sodium_hydroxide"] = {elem1: "sodium_carbonate_solution", elem2: null};
elements["baking_soda_solution"].reactions["sodium_hydroxide_gas"] = {elem1: "sodium_carbonate_solution", elem2: null};
createSalt("sodium_acetate","sodium_acetate_solution",["#f2f2f2","#e0e0e0"],"#7ea2f2",false,true,292,-2,102,3980,1028,"SODIUM","ACETATE");
@ -6035,7 +6084,6 @@ runAfterAutogen(function() {
let i = eLists.WATER[ii];
if(!elements[i])
{
console.log(i);
continue;
}
if(!elements[i].reactions)
@ -6106,11 +6154,11 @@ runAfterAutogen(function() {
if(productsA.length > 0 && productsB.length > 0)
{
acidReact(i,j,productsA,productsB,0);
console.log("precipitate");
console.log(i);
console.log(j);
console.log(productsA);
console.log(productsB);
//console.log("precipitate");
//console.log(i);
//console.log(j);
//console.log(productsA);
//console.log(productsB);
priorityA = elements[i].salt[iii].priority;
priorityB = elements[j].salt[jjj].priority;
continue;
@ -6142,10 +6190,10 @@ runAfterAutogen(function() {
if(productsA.length > 0 && productsB.length > 0)
{
elements[i].reactions[j] = { elem1:productsA, elem2:productsB, chance:0.001, oneway:true };
console.log(i);
console.log(j);
console.log(productsA);
console.log(productsB);
//console.log(i);
//console.log(j);
//console.log(productsA);
//console.log(productsB);
priorityA = elements[i].salt[iii].priority;
priorityB = elements[j].salt[jjj].priority;
}
@ -6161,7 +6209,6 @@ runAfterAutogen(function() {
let i = acids[ii];
if(!elements[i])
{
console.log(i);
continue;
}
if(!elements[i].reactions)
@ -6234,14 +6281,36 @@ runAfterAutogen(function() {
reactionTemp = 50;
}
acidReact(i,j,productsA,productsB,reactionTemp);
console.log("neutral");
console.log(i);
console.log(j);
console.log(compounds);
console.log(productsA);
console.log(productsB);
if(elements[j].reactions && elements[j].reactions[i]) {
delete elements[j].reactions[i];
}
for(let k = 0; k < productsA.length; k++)
{
if(elements[j].reactions && elements[j].reactions[productsA[k]]) {
delete elements[j].reactions[productsA[k]];
}
if(elements[i].reactions && elements[i].reactions[productsA[k]]) {
delete elements[i].reactions[productsA[k]];
}
}
for(let k = 0; k < productsB.length; k++)
{
if(elements[j].reactions && elements[j].reactions[productsB[k]]) {
delete elements[j].reactions[productsB[k]];
}
if(elements[i].reactions && elements[i].reactions[productsB[k]]) {
delete elements[i].reactions[productsB[k]];
}
}
//console.log("neutral");
//console.log(i);
//console.log(j);
//console.log(compounds);
//console.log(productsA);
//console.log(productsB);
}
}
}
delete elements["molten_iodine_ice"];
}
});

View File

@ -1385,7 +1385,20 @@ window.libraryLoaded = true;
if(Array.isArray(breakIntoElement)) {
breakIntoElement = breakIntoElement[Math.floor(Math.random() * breakIntoElement.length)]
};
changePixel(pixel,breakIntoElement,changetemp)
var result = breakIntoElement;
// change the pixel to the result
if (result === null) {
deletePixel(pixel.x,pixel.y);
return;
}
if (elements[pixel.element].breakIntoColor) {
var oldelement = pixel.element;
changePixel(pixel,result,changetemp);
pixel.color = pixelColorPick(pixel, elements[oldelement].breakIntoColor);
}
else {
changePixel(pixel,result,changetemp);
}
};
function tryBreak(pixel,changetemp=false,defaultBreakIntoDust=false) {

View File

@ -0,0 +1,75 @@
document.onkeydown = function(ki)/*keyboard_input*/ {
//a
if (ki.keyCode == 65) {
KA = true;
//vX ++;
}
//d
if (ki.keyCode == 68) {
KD = true;
//vX ++;
}
//w
if (ki.keyCode == 87) {
KW = true;
//vY ++;
}
//s
if (ki.keyCode == 83) {
KS = true;
//vY ++;
}
}
document.onkeyup = function(i2)/*keyboard_input*/ {
//a
if (i2.keyCode == 65) {
KA = false;
//vX --;
}
//d
if (i2.keyCode == 68) {
KD = false;
//vX --;
}
//w
if (i2.keyCode == 87) {
KW = false;
//vY = 0;
}
//s
if (i2.keyCode == 83) {
KS = false;
//vY = 0;
}
}
var KA = false;
var KD = false;
var KW = false;
var KS = false;
var vX = 1;
var vY = 1;
elements.c_pixel = {
tick: function(pixel) {
/*if (vX === 3) {
vX --;
}
if (vY === 3) {
vY --;
}*/
if (KA === true) {
tryMove (pixel,pixel.x-vX,pixel.y)
}
if (KD === true) {
tryMove (pixel,pixel.x+vX,pixel.y)
}
if (KW === true) {
tryMove (pixel,pixel.x,pixel.y-vY)
}
if (KS === true) {
tryMove (pixel,pixel.x,pixel.y+vY)
}
},
category: "special",
states:"solid",
color:"#FFFFFF",
}

View File

@ -266,8 +266,19 @@ elements.plasma.tick = function(pixel) {
};
// Wait for loading
// if it loads too soon then width will be undefined
setTimeout(() => { initializeLightmap(width, height); }, 700);
let i = 0;
let interval = setInterval(() => {
if (typeof width !== 'undefined') {
clearInterval(interval);
initializeLightmap(width, height);
}
i += 1;
// if width is not defined for 3 seconds or longer, it's probably broken, so it will just try run the function anyways to see the error
if (i >= 30) {
clearInterval(interval);
initializeLightmap(width, height);
}
}, 100);
// Add code to functions instead of replacing them
let originalTick = tick;

595
mods/sturdierpowders.js Normal file
View File

@ -0,0 +1,595 @@
tryMove = function(pixel,nx,ny,leaveBehind,force) {
if (pixel.drag && !force) { return true; }
var info = elements[pixel.element];
var oob = outOfBounds(nx,ny);
if (isEmpty(nx,ny,false,oob)) { // If coords is empty, move to coords
if(Math.random() > (elements[newPixel.element].friction ? elements[newPixel.element].friction : 0.02))
{
pixel.grounded = true;
}
else
{
pixel.grounded = false;
}
movePixel(pixel,nx,ny,leaveBehind);
return true;
}
else if (!oob) {
// Reactions
newPixel = pixelMap[nx][ny];
if(!pixel.grounded && Math.random() > (elements[newPixel.element].friction ? elements[newPixel.element].friction : 0.02)) {
newPixel.grounded = false;
}
if(Math.random() > (elements[newPixel.element].friction ? elements[newPixel.element].friction : 0.02))
{
pixel.grounded = true;
}
var rr1 = false;
if (info.reactions !== undefined && info.reactions[newPixel.element] !== undefined) {
rr1 = reactPixels(pixel,newPixel)
if (rr1) {
return true;
}
}
if (!rr1 && elements[newPixel.element].reactions !== undefined && elements[newPixel.element].reactions[pixel.element] !== undefined && !elements[newPixel.element].reactions[pixel.element].oneway) {
if (reactPixels(newPixel,pixel)) {
return true;
}
}
// Density
if (elements[pixel.element].id !== elements[newPixel.element].id) {
if (info.density !== undefined && elements[newPixel.element].density !== undefined) {
// if the pixel's state + ">" + newPixel's state is in validDensitySwaps, and the pixel's density is larger than the newPixel's density, swap the pixels
if (validDensitySwaps[info.state][elements[newPixel.element].state] && info.density >= elements[newPixel.element].density) {
// chance depending on the difference in density
if (Math.random() < (info.density - elements[newPixel.element].density)/(info.density + elements[newPixel.element].density)) {
swapPixels(pixel,newPixel);
return true;
}
}
}
}
// else { // same-element density swapping
// if (info.density !== undefined) {
// if (validDensitySwaps[info.state][info.state]) {
// if (Math.random() < 0.01) {
// swapPixels(pixel,newPixel);
// return true;
// }
// }
// }
// }
}
return false;
}
function pixelTick(pixel,custom=null) {
if (pixel.start === pixelTicks) {return}
if (elements[pixel.element] === undefined) {
pixel.invalidElement = pixel.element;
changePixel(pixel,"unknown");
return;
}
var info = elements[pixel.element];
if (custom) { var behavior = custom; }
else if (pixel.charge && info.behaviorOn) { var behavior = info.behaviorOn; }
else { var behavior = info.behavior; }
if (pixel.flipX) { behavior = flipBehavior(behavior,"x"); }
if (pixel.flipY) { behavior = flipBehavior(behavior,"y"); }
if (pixel.r) { behavior = rotateBehavior(behavior,pixel.r); }
var x = pixel.x;
var y = pixel.y;
var move1Spots = [];
var move2Spots = [];
var supportSpots = [];
var swapSpots = [];
var leaveBehind = null;
var leaveBehind1 = null;
var leaveBehind2 = null;
var move = true;
// Parse behavior
for (var by = 0; by < behavior.length; by++) {
var behaviorby = behavior[by];
for (var bx = 0; bx < behaviorby.length; bx++) {
var b0 = behaviorby[bx];
if (b0 === "XX") {continue}
//if (b.includes(" OR ")) {
// b = b.split(" OR ")[Math.floor(Math.random()*b.split(" OR ").length)];
//}
// Loop through b0.split(" AND ")
if (b0.indexOf(" AND ") !== -1) { var andsplit = b0.split(" AND "); }
else { var andsplit = [b0]; }
for (var i = 0; i < andsplit.length; i++) {
var b = andsplit[i];
if (b.indexOf(":") !== -1) {
var arg = b.split(":")[1].split(/[\:\%]/)[0];
if (b.indexOf("%") === -1) {
b = b.split(/[\:\%]/)[0];
}
}
else { var arg = null;}
// If b has "%" followed by a number in it, it's a chance to move
if (b.indexOf("%") !== -1) {
// Split the string at the "%" and use the second half as the chance (float)
var chance = parseFloat(b.split("%")[1]);
//console.log(b+": "+(Math.random()*100 < chance));
b = b.split(/[\:\%]/)[0];
}
else { var chance = 100; }
if (chance===100 || Math.random()*100 < chance) {
var newCoords = behaviorCoords(x,y,bx,by);
switch (b) {
default: break;
case "M1":
if (info.viscosity !== undefined) {
if (!((Math.random()*100) < 100 / Math.pow(info.viscosity, 0.25))) {
newCoords.x = x;
}
}
move1Spots.push(newCoords);
break;
case "M2":
if (pixel.grounded || info.viscosity !== undefined) {
if (!((Math.random()*100) < 100 / Math.pow(info.viscosity, 0.25))) {
newCoords.x = x;
}
}
move2Spots.push(newCoords);
break;
case "SP":
supportSpots.push({x:newCoords.x,y:newCoords.y,arg:arg});
break;
case "SA":
if (!isEmpty(newCoords.x,newCoords.y,true)) {
move = false;
}
break;
case "DL":
if (!isEmpty(newCoords.x,newCoords.y,true)) {
// if the pixel at newCoords is the same element as the pixel, ignore
newPixel = pixelMap[newCoords.x][newCoords.y];
// if info.ignore exists and newPixel.element is in it
if (info.ignore && info.ignore.indexOf(newPixel.element) !== -1) {
continue;
}
if ((!(newPixel.element == pixel.element)) || (newCoords.x == x && newCoords.y == y)) {
if (arg != null) { var args = arg.split(","); }
if (arg == null || args.indexOf(newPixel.element) !== -1) {
if (!elements[newPixel.element].hardness || Math.random() > elements[newPixel.element].hardness) {
deletePixel(newCoords.x,newCoords.y);
if (newCoords.x == x && newCoords.y == y) {
var deleted = true;
}
swapSpots = [];
}
}
}
}
break;
case "DB":
if (!isEmpty(newCoords.x,newCoords.y,true)) {
// if the pixel at newCoords is the same element as the pixel, ignore
newPixel = pixelMap[newCoords.x][newCoords.y];
// if info.ignore exists and newPixel.element is in it
if (info.ignore && info.ignore.indexOf(newPixel.element) !== -1) {
continue;
}
if (!(newPixel.element == pixel.element)) {
if (arg != null) { var args = arg.split(","); }
if (arg == null || args.indexOf(newPixel.element) !== -1) {
if (!elements[newPixel.element].hardness || Math.random() > elements[newPixel.element].hardness) {
deletePixel(newCoords.x,newCoords.y);
if (pixelMap[pixel.x][pixel.y] != undefined) {
deletePixel(pixel.x,pixel.y);
}
var deleted = true;
swapSpots = [];
}
}
}
}
break;
case "CH":
if (!isEmpty(newCoords.x,newCoords.y,true)) {
var newPixel = pixelMap[newCoords.x][newCoords.y];
if (info.ignore && info.ignore.indexOf(newPixel.element) !== -1) {
continue;
}
if (!elements[newPixel.element].hardness || Math.random() > elements[newPixel.element].hardness || (newCoords.x == x && newCoords.y == y)) {
if (arg.indexOf(">") !== -1) {
var argfrom = arg.split(">")[0];
if (argfrom.indexOf(",") !== -1) {
if (argfrom.split(",").indexOf(newPixel.element) === -1) {
continue;
}
}
else if (argfrom !== newPixel.element) {
continue;
}
var argto = arg.split(">")[1];
}
else {
var argfrom = null;
var argto = arg;
}
if (argto.indexOf(",") !== -1) {
var argto = argto.split(",")[Math.floor(Math.random()*argto.split(",").length)];
}
if (elements[argto]) {
if (elements[newPixel.element].id !== elements[argto].id) {
changePixel(newPixel,argto);
}
}
}
}
break;
case "SW":
if (!isEmpty(newCoords.x,newCoords.y,true)) {
var newPixel = pixelMap[newCoords.x][newCoords.y];
if (arg != null) { var args = arg.split(","); }
if (arg == null || args.indexOf(newPixel.element) !== -1) {
if (!elements[newPixel.element].hardness || Math.random() > elements[newPixel.element].hardness) {
swapSpots.push({x:newCoords.x,y:newCoords.y});
}
}
}
break;
case "CR":
if (isEmpty(newCoords.x,newCoords.y)) {
if (arg == null) {
arg = pixel.element;
}
else if (arg.indexOf(",") !== -1) {
arg = arg.split(",")[Math.floor(Math.random()*arg.split(",").length)];
}
if (elements[arg]) {
createPixel(arg,newCoords.x,newCoords.y);
if (info.fireColor && arg==="fire") {
pixelMap[newCoords.x][newCoords.y].color = pixelColorPick(pixelMap[newCoords.x][newCoords.y],info.fireColor);
}
pixelMap[newCoords.x][newCoords.y].temp = pixel.temp
pixelTempCheck(pixelMap[newCoords.x][newCoords.y]);
}
}
break;
case "CL":
if (isEmpty(newCoords.x,newCoords.y)) {
if (arg == null || pixel.temp >= parseFloat(arg)) {
clonePixel(pixel,newCoords.x,newCoords.y);
}
}
break;
case "CF":
if (pixel.clone) {
if (isEmpty(newCoords.x,newCoords.y)) {
createPixel(pixel.clone,newCoords.x,newCoords.y);
pixelMap[newCoords.x][newCoords.y].temp = pixel.temp;
pixelTempCheck(pixelMap[newCoords.x][newCoords.y]);
}
}
else {
if (!isEmpty(newCoords.x,newCoords.y,true)) {
newPixel = pixelMap[newCoords.x][newCoords.y];
if (info.ignore && info.ignore.indexOf(newPixel.element) !== -1) {
continue;
}
if (newPixel.element != pixel.element && newPixel.element != "wire") {
pixel.clone = newPixel.element;
pixel.temp = newPixel.temp;
}
else if (newPixel.clone) {
pixel.clone = newPixel.clone;
pixel.temp = newPixel.temp;
}
}
}
break;
case "SH":
if (!isEmpty(newCoords.x,newCoords.y,true)) {
var newPixel = pixelMap[newCoords.x][newCoords.y];
var con = elements[newPixel.element].conduct;
if (con != undefined) {
if (Math.random() < con) { // If random number is less than conductivity
if (!newPixel.charge && !newPixel.chargeCD && (arg == null || newPixel.element == arg)) {
newPixel.charge = (parseFloat(arg) || 1);
if (elements[newPixel.element].colorOn) {
newPixel.color = pixelColorPick(newPixel);
}
}
}
}
}
break;
case "ST": //Stick
if (!isEmpty(newCoords.x,newCoords.y,true)) {
var newPixel = pixelMap[newCoords.x][newCoords.y];
if (info.ignore && info.ignore.indexOf(newPixel.element) !== -1) {
continue;
}
if (newPixel.element != pixel.element && (arg == null || newPixel.element == arg)) {
var sticking = true
}
}
break;
case "LB":
case "L1":
case "L2":
if (arg != null && arg.indexOf(",") !== -1) {
arg = arg.split(",")[Math.floor(Math.random()*arg.split(",").length)];
}
if (elements[arg]) {
if (b=="LB") {leaveBehind = arg;}
else if (b=="L1") {leaveBehind1 = arg;}
else if (b=="L2") {leaveBehind2 = arg;}
}
break;
case "CC":
if (!isEmpty(newCoords.x,newCoords.y,true)) {
var newPixel = pixelMap[newCoords.x][newCoords.y];
if (arg == null) {arg = newPixel.colorObject}
else {
if (arg.indexOf(",") !== -1) {
arg = arg.split(",")[Math.floor(Math.random()*arg.split(",").length)];
}
if (!arg.startsWith("#")) {
arg = "#" + arg;
}
}
newPixel.color = pixelColorPick(newPixel,arg);
}
break;
case "HT":
if (!isEmpty(newCoords.x,newCoords.y,true)) {
var newPixel = pixelMap[newCoords.x][newCoords.y];
// if the element isn't the same or the coords ARE the same
if (!(newPixel.element == pixel.element) || (newCoords.x == pixel.x && newCoords.y == pixel.y)) {
if (arg != null) {arg = parseFloat(arg)}
else {arg = 1}
if (isNaN(arg)) {arg = 1}
newPixel.temp += arg;
pixelTempCheck(newPixel);
}
}
break;
case "CO":
if (!isEmpty(newCoords.x,newCoords.y,true)) {
var newPixel = pixelMap[newCoords.x][newCoords.y];
if (!(newPixel.element == pixel.element) || (newCoords.x == pixel.x && newCoords.y == pixel.y)) {
if (arg != null) {arg = parseFloat(arg)}
else {arg = 1}
if (isNaN(arg)) {arg = 1}
newPixel.temp -= arg;
pixelTempCheck(newPixel);
}
}
break;
case "FX":
if (!isEmpty(newCoords.x,newCoords.y,true)) {
var newPixel = pixelMap[newCoords.x][newCoords.y];
if (elements[newPixel.element].flippableX) {
if (arg === "0") { newPixel.flipX = false; }
else if (arg === "1") { newPixel.flipX = true; }
newPixel.flipX = !newPixel.flipX;
}
}
break;
case "FY":
if (!isEmpty(newCoords.x,newCoords.y,true)) {
var newPixel = pixelMap[newCoords.x][newCoords.y];
if (elements[newPixel.element].flippableY) {
if (arg === "0") { newPixel.flipY = false; }
else if (arg === "1") { newPixel.flipY = true; }
else { newPixel.flipY = !newPixel.flipY; }
}
}
break;
case "RT":
if (!isEmpty(newCoords.x,newCoords.y,true)) {
var newPixel = pixelMap[newCoords.x][newCoords.y];
// If arg isn't null, set arg to a random choice from arg.split(",")
if (arg != null && arg.indexOf(",") !== -1) {
arg = arg.split(",")[Math.floor(Math.random()*arg.split(",").length)];
}
if (elements[newPixel.element].rotatable) {
newPixel.r = ((newPixel.r||0) + (parseInt(arg)||1)) % 4;
}
}
break;
case "BO":
if (!isEmpty(newCoords.x,newCoords.y) && (outOfBounds(newCoords.x,newCoords.y) || elements[pixelMap[newCoords.x][newCoords.y].element].id === elements[pixel.element].id || elements[pixelMap[newCoords.x][newCoords.y].element].state === "solid")) {
if (info.flippableX) {
pixel.flipX = !pixel.flipX;
}
if (info.flippableY) {
pixel.flipY = !pixel.flipY;
}
if (info.rotatable) {
// If arg isn't null, set arg to a random choice from arg.split(",")
if (arg != null && arg.indexOf(",") !== -1) {
arg = arg.split(",")[Math.floor(Math.random()*arg.split(",").length)];
}
if (pixel.r !== undefined) {
pixel.r = (pixel.r + (parseInt(arg)||2)) % 4;
}
else { pixel.r = (parseInt(arg)||2); }
}
}
break;
case "C2":
if (arg.indexOf(",") !== -1) {
arg = arg.split(",")[Math.floor(Math.random()*arg.split(",").length)];
}
var C2 = arg;
break;
case "EX":
if (!isEmpty(newCoords.x,newCoords.y)) {
if (outOfBounds(newCoords.x,newCoords.y) || (newCoords.x == x && newCoords.y == y) || (pixel.element !== pixelMap[newCoords.x][newCoords.y].element && elements[pixelMap[newCoords.x][newCoords.y].element].state !== "gas")) {
// if arg contains ">", var fire = everything after it, arg = everything before it
if (arg.indexOf(">") !== -1) {
var fire = arg.split(">")[1];
arg = arg.split(">")[0];
}
else { var fire = "fire" }
// arg = a number
if (arg != null) {
arg = parseInt(arg);
if (isNaN(arg)) {arg = 3}
}
else {arg = 3}
explodeAt(x,y,arg,fire);
if (!pixel.del && info.hardness !== 1) {
deletePixel(x,y);
var deleted = true;
}
swapSpots = [];
}
}
break;
}
}
}
}
}
if (typeof deleted !== "undefined") {return;}
if (supportSpots.length > 0) {
var supportCount = 0;
var allEmpty = true;
for (var i = 0; i < supportSpots.length; i++) {
var bx = supportSpots[i].x;
var by = supportSpots[i].y;
var arg = supportSpots[i].arg;
if (!isEmpty(bx,by,true)) {
if (info.ignore && info.ignore.indexOf(pixelMap[bx][by].element) !== -1) {continue;}
if ((arg == null && !validDensitySwaps[info.state][elements[pixelMap[bx][by].element].state]) || pixelMap[bx][by].element == arg) {
supportCount++;
}
}
}
if (supportCount == supportSpots.length) {
move = false;
}
}
var moved = false;
if (swapSpots.length > 0) {
var coords = swapSpots[Math.floor(Math.random()*swapSpots.length)];
if (pixelMap[coords.x][coords.y] != undefined) {
swapPixels(pixel,pixelMap[coords.x][coords.y]);
move = false;
moved = true;
}
}
if (typeof sticking !== "undefined") {
move = false;
}
// Move First Priority
if (move) {
if (move1Spots.length > 0) {
// While move1Spots is not empty
while (move1Spots.length > 0) {
// coords = random item of move1Spots
var coords = move1Spots[Math.floor(Math.random()*move1Spots.length)];
var nx = coords.x;
var ny = coords.y;
moved = tryMove(pixel,nx,ny,leaveBehind1 || leaveBehind);
if (moved) {
break;
}
else {
// remove coords from move1Spots
move1Spots.splice(move1Spots.indexOf(coords),1);
}
}
}
// Move Second Priority
if (!moved && move2Spots.length > 0) {
// While move2Spots is not empty
while (move2Spots.length > 0) {
// coords = random item of move2Spots
var coords = move2Spots[Math.floor(Math.random()*move2Spots.length)];
var nx = coords.x;
var ny = coords.y;
moved = tryMove(pixel,nx,ny,leaveBehind2 || leaveBehind);
if (moved) {
if (typeof C2 !== "undefined" && elements[C2]) {
changePixel(pixel,C2);
}
break;
}
else {
// remove coords from move2Spots
move2Spots.splice(move2Spots.indexOf(coords),1);
}
}
}
}
doAirDensity(pixel);
// Change tempearture if needed (unused)
/*if (info.tempChange != undefined) {
pixel.temp += info.tempChange;
pixelTempCheck(pixel);
}*/
// Burning
doBurning(pixel);
// Heat Transfer
if (info.insulate !== true) {
doHeat(pixel);
}
// Electricity Transfer
doElectricity(pixel);
// Staining
if (info.stain) {
doStaining(pixel);
}
}
behaviors.POWDER2 = function(pixel) {
if (pixel.start === pixelTicks) {return}
if (pixel.charge && elements[pixel.element].behaviorOn) {
pixelTick(pixel)
}
console.log(pixel.grounded);
if (!pixel.grounded) {
if(!tryMove(pixel, pixel.x, pixel.y+1)) {
if (Math.random() < 0.5) {
if (!tryMove(pixel, pixel.x+1, pixel.y+1)) {
tryMove(pixel, pixel.x-1, pixel.y+1);
}
} else {
if (!tryMove(pixel, pixel.x-1, pixel.y+1)) {
tryMove(pixel, pixel.x+1, pixel.y+1);
}
}
}
}
else
{
tryMove(pixel, pixel.x, pixel.y+1);
}
doDefaults(pixel);
}
runAfterLoad(function() {
for(let i in elements) {
if(elements[i].behavior === behaviors.POWDER) {
elements[i].behavior = behaviors.POWDER2;
}
}
});

View File

@ -50,7 +50,7 @@ var Simple1DNoise = function() {
};
};
function newHeightMap(pixelType, pixelType2, offset, amplitude1, amplitude2, scale1, scale2) {
function newHeightMap(pixelType, pixelType2, offset, amplitudes, scales) {
return {
color: "#000000",
behavior: behaviors.WALL,
@ -61,22 +61,23 @@ function newHeightMap(pixelType, pixelType2, offset, amplitude1, amplitude2, sca
pixelType: pixelType,
pixelType2: pixelType2,
offset: offset,
amplitude1: amplitude1,
amplitude2: amplitude2,
scale1: scale1,
scale2: scale2,
generator: new Simple1DNoise(),
generator2: new Simple1DNoise(),
amplitudes: amplitudes,
scales: scales,
generator: Array.from({length: amplitudes.length}, () => new Simple1DNoise()),
excludeRandom: true,
heightMap: true,
tick: function(pixel) {
generator = this.generator;
generator2 = this.generator2;
generator.setAmplitude(this.amplitude1);
generator.setScale(this.scale1);
generator2.setAmplitude(this.amplitude2);
generator2.setScale(this.scale2);
let value = generator.getVal(pixel.x/width) + generator2.getVal(pixel.x/width);
if(value + this.offset < pixel.y/height) {
let generator = this.generator;
for(let i = 0; i < generator.length; i++)
{
generator[i].setAmplitude(this.amplitudes[i]);
generator[i].setScale(this.scales[i]);
}
let value = generator.reduce((accumulator, val) => {
return accumulator + val.getVal(pixel.x/width);
console.log(accumulator);
},0);
if(value + this.offset + generateTerrainHeights() < pixel.y/height) {
let element = this.pixelType;
if(Array.isArray(element))
{
@ -87,6 +88,10 @@ function newHeightMap(pixelType, pixelType2, offset, amplitude1, amplitude2, sca
deletePixel(pixel.x,pixel.y);
} else {
changePixel(pixel,element);
if(elements[element].heightMap)
{
elements[element].tick(pixel);
}
}
} else {
let element = this.pixelType2;
@ -99,15 +104,24 @@ function newHeightMap(pixelType, pixelType2, offset, amplitude1, amplitude2, sca
deletePixel(pixel.x,pixel.y);
} else {
changePixel(pixel,element);
if(elements[element].heightMap)
{
elements[element].tick(pixel);
}
}
}
}
};
}
elements.dunes_height_map = newHeightMap("sand", null, 0, 0.75, 0.05, 2.5, 20);
elements.oasis_height_map = newHeightMap("sand", "water_height", 0.25, 0.75, 0.05, 2.5, 20);
elements.water_height = newHeightMap("water", null, 0.5, 0, 0, 1, 1);
elements.dunes_height_map = newHeightMap("sand", null, 0.25, [0.75, 0.05, 0.02], [2.5, 20, 200]);
elements.oasis = newHeightMap("water_height", "oasis_height_map", 0.5, [0.02], [200]);
elements.oasis_height_map = newHeightMap("sand", null, 0.25, [0.75, 0.05, 0.02], [2.5, 20, 200]);
elements.oasis_height_map2 = newHeightMap("sand", "packed_sand", 0.28, [0.75, 0.05, 0.02], [2.5, 20, 200]);
elements.oasis_height_map2.generator = elements.oasis_height_map.generator;
elements.water_height = newHeightMap("oasis_height_map2", "water", 0.25, [0.75, 0.05, 0.02], [2.5, 20, 200]);
elements.water_height.generator = elements.oasis_height_map.generator;
worldgentypes.dunes = {
fill: [
[0, "dunes_height_map"]
@ -115,21 +129,21 @@ worldgentypes.dunes = {
};
worldgentypes.oasis = {
fill: [
[0, "oasis_height_map"]
[0, "oasis"]
]
};
if (enabledMods.includes("mods/chem.js")) {
elements.ptfe_height_map = newHeightMap("polytetrafluoroethylene", "foof_height", 0.25, 0.75, 0.05, 2.5, 20);
elements.foof_height = newHeightMap("FOOF", Array(100).fill(null).concat(["oxygen","fluorine"]), 0.5, 0, 0, 1, 1);
elements.ptfe_height_map = newHeightMap("polytetrafluoroethylene", "foof_height", 0.5, [0.5, 0.05, 0.02], [2.5, 20, 200]);
elements.foof_height = newHeightMap("foof", Array(100).fill(null).concat(["oxygen","fluorine"]), 0.5, [], []);
worldgentypes.FOOF_sea = {
fill: [
[0, "ptfe_height_map"]
],
temperature: -120
};
elements.francium_height_map = newHeightMap("tungsten", "francium_height", 0.125, 1, 0.2, 2.5, 20);
elements.francium_height = newHeightMap("molten_francium", Array(100).fill(null).concat(["radon","radiation","radiation","radiation"]), 0.5, 0, 0, 1, 1);
elements.francium_height_map = newHeightMap("tungsten", "francium_height", 0.375, [1, 0.2, 0.02], [2.5, 20, 200]);
elements.francium_height = newHeightMap("molten_francium", Array(100).fill(null).concat(["radon","radiation","radiation","radiation"]), 0.5, [], []);
worldgentypes.francium_lake = {
fill: [
[0, "francium_height_map"]