From 2db2b0c24f5702985a0d9f4b5412ac728c0e9406 Mon Sep 17 00:00:00 2001 From: "Laetitia (O-01-67)" <68935009+O-01-67@users.noreply.github.com> Date: Sun, 12 Feb 2023 10:24:44 -0500 Subject: [PATCH] movable criteria --- mods/code_library.js | 49 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/mods/code_library.js b/mods/code_library.js index 885ed8f2..c5190e46 100644 --- a/mods/code_library.js +++ b/mods/code_library.js @@ -172,6 +172,55 @@ }; }; + //Is movable + var backupCategoryWhitelist = ["land","powders","weapons","food","life","corruption","states","fey","Fantastic Creatures","dyes","energy liquids","random liquids","random gases","random rocks"]; + var backupElementWhitelist = ["mercury", "chalcopyrite_ore", "chalcopyrite_dust", "copper_concentrate", "fluxed_copper_concentrate", "unignited_pyrestone", "ignited_pyrestone", "everfire_dust", "extinguished_everfire_dust", "mistake", "polusium_oxide", "vaporized_polusium_oxide", "glowstone_dust", "redstone_dust", "soul_mud", "wet_soul_sand", "nitrogen_snow", "fusion_catalyst", "coal", "coal_coke", "blast_furnace_fuel", "molten_mythril"]; + + function commonMovableCriteria(name,shallowBlacklist=null) { + if(typeof(elements[name]) !== "object") { + throw new Error(`Nonexistent element ${name}`); + }; + var info = elements[name]; + //console.log(`${name} (${JSON.stringify(elements[name])})`); + if(typeof(info.state) === "undefined") { + var state = null; + } else { + var state = info.state; + }; + if(typeof(info.category) === "undefined") { + var category = "other"; + } else { + var category = info.category; + }; + if(shallowBlacklist !== null) { + if(shallowBlacklist.includes(name)) { + return false; + }; + }; + if(shallowBlacklist !== null && shallowBlacklist.includes(name)) { + return false + }; + if(elements[name].behavior && elements[name].behavior.toString() == elements.wall.behavior.toString() && !elements[name].tick) { + return false; + }; + if(["liquid","gas"].includes(state)) { + return true; + }; + if(info.movable) { + return true; + }; + if(backupCategoryWhitelist.includes(category)) { + return true; + }; + if(backupElementWhitelist.includes(name)) { + return true; + }; + if(category.includes("mudstone")) { + return true; + }; + return false; + }; + //Math(s) //Distance between points