var ignorelist = [];
// if you want to ignore vanilla elements, uncomment this large array:
//var ignorelist = ['heat','cool','erase','pick','mix','lookup','shock','paint','unpaint','sand','water','salt_water','sugar_water','seltzer','dirty_water','pool_water','dirt','mud','wet_sand','rock','mudstone','packed_sand','plant','dead_plant','frozen_plant','grass','algae','concrete','wall','fire','bomb','steam','ice','snow','packed_snow','wood','smoke','magma','plasma','cold_fire','glass','molten_glass','rad_glass','meat','rotten_meat','cooked_meat','frozen_meat','chocolate','cloner','ecloner','slow_cloner','wire','random','uncharge','unburn','smash','filler','lattice','gravel','slime','cement','dust','void','sun','cell','cancer','dna','plague','flea','termite','ant','worm','fly','firefly','bee','stink_bug','dead_bug','human','body','head','bird','rat','frog','frozen_frog','tadpole','fish','slug','snail','heater','cooler','superheater','freezer','torch','spout','udder','bone_marrow','bone','antipowder','antimolten','antifire','antifluid','antigas','vertical','horizontal','rocket','ash','light','laser','ball','pointer','charcoal','tinder','sawdust','salt','hail','hydrogen','oxygen','nitrogen','helium','anesthesia','ammonia','liquid_ammonia','carbon_dioxide','oil','lamp_oil','propane','methane','stained_glass','molten_stained_glass','art','rainbow','static','border','clay','clay_soil','brick','ruins','sapling','seeds','grass_seed','wheat_seed','straw','paper','pollen','flower_seed','pistil','petal','tree_branch','vine','bamboo','bamboo_plant','burner','foam','bubble','acid','neutral_acid','acid_gas','glue','soda','gray_goo','malware','clone_powder','floating_cloner','virus','ice_nine','strange_matter','permafrost','cheese','melted_cheese','mushroom_spore','mushroom_stalk','mushroom_gill','mushroom_cap','hyphae','mycelium','lichen','antimatter','plastic','molten_plastic','cellulose','wax','melted_wax','incense','fuse','dioxin','insulation','sponge','iron','copper','gold','nickel','zinc','silver','tin','lead','aluminum','tungsten','molten_tungsten','brass','bronze','sterling','steel','gallium','molten_gallium','rose_gold','electrum','solder','molten_copper','molten_gold','molten_iron','pyrite','molten_tin','juice','broth','milk','chocolate_milk','fruit_milk','yogurt','frozen_yogurt','egg','yolk','homunculus','hard_yolk','grape','vinegar','corn','popcorn','corn_seed','potato_seed','potato','root','fiber','yeast','bread','toast','wheat','flour','dough','sugar','candy','baking_soda','sodium_acetate','dry_ice','nitrogen_ice','porcelain','particleboard','alcohol','basalt','soap','bleach','chlorine','liquid_chlorine','dye','ink','mercury','blood','vaccine','antibody','infection','poison','poison_gas','antidote','honey','sap','caramel','molasses','ketchup','melted_chocolate','liquid_hydrogen','liquid_oxygen','liquid_nitrogen','liquid_helium','sodium','calcium','limestone','quicklime','slaked_lime','thermite','molten_thermite','slag','amalgam','molten_aluminum','molten_zinc','neon','liquid_neon','smog','stench','fragrance','cyanide','ozone','cloud','rain_cloud','snow_cloud','hail_cloud','acid_cloud','pyrocumulus','fire_cloud','color_smoke','spray_paint','battery','led_r','led_g','led_b','sulfur','molten_sulfur','sulfur_gas','copper_sulfate','snake','loopy','radiation','rad_steam','rad_cloud','fallout','neutron','proton','electric','uranium','molten_uranium','diamond','gold_coin','rust','oxidized_copper','metal_scrap','glass_shard','brick_rubble','baked_clay','feather','glitter','bead','color_sand','borax','epsom_salt','potassium_salt','explosion','n_explosion','supernova','pop','cook','incinerate','room_temp','positron','tnt','c4','grenade','dynamite','gunpowder','ember','firework','fw_ember','nuke','h_bomb','dirty_bomb','emp_bomb','nitroglycerin','greek_fire','sticky_bomb','cold_bomb','hot_bomb','electro_bomb','water_bomb','antimatter_bomb','flashbang','flash','smoke_grenade','fireball','landmine','cluster_bomb','armageddon','tesla_coil','light_bulb','shocker','pressure_plate','primordial_soup','molten_slag','molten_dirt','debug','salt_ice','sugar_ice','seltzer_ice','dirty_ice','pool_ice','blood_ice','antibody_ice','infection_ice','molten_rad_glass','slime_ice','antiice','molten_salt','liquid_propane','liquid_methane','molten_brick','acid_ice','molten_nickel','molten_silver','molten_lead','molten_brass','molten_bronze','molten_sterling','molten_steel','gallium_gas','molten_rose_gold','molten_electrum','molten_solder','molten_pyrite','juice_ice','molten_baking_soda','alcohol_gas','alcohol_ice','chlorine_ice','mercury_gas','solid_mercury','hydrogen_ice','oxygen_ice','molten_sodium','molten_calcium','molten_amalgam','molten_copper_sulfate','molten_borax','molten_epsom_salt','molten_potassium_salt','slush','balloon','molten_ash','pinecone','evergreen','pilk','eggnog','gingerbread','beans','alga','confetti','party_popper','molten_sodium_acetate','molten_alga'];s
var categories = {"tools": 137,"land": 140,"liquids": 141,"life": 142,"powders": 143,"solids": 144,"energy": 145,"weapons": 146,"gases": 147,"states": 148,"food": 149,"machines": 150}
// Elements
// ,NAME,ELEMENT ID|WITHOUT UNDERSCORES,instance of,ELEMENT ID,HEX COLOR,STATE,CATEGORY,HIDDEN,TOOL,description
//qid,Len,Aen,P1,P26,P57,P1,P4,P1,P1,Den
var lines = [];
for (id in elements) {
if (ignorelist.indexOf(id) !== -1) continue;
lines.push("CREATE")
var info = elements[id];
// name = replace underscores with spaces and capitalize first letters of each word
var elemname = (info.name||id.replace(/_/g, ' ')).replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
lines.push("LAST\tLen\t\""+elemname+"\"");
lines.push("LAST\tAen\t\""+id+"\"");
// if there is an underscore in the ID, add another alias with spaces instead
if (id.indexOf("_") > -1) {
lines.push("LAST\tAen\t\""+id.replace(/_/g, ' ')+"\"");
}
lines.push("LAST\tP1\tQ59");
lines.push("LAST\tP26\t\""+id+"\"");
var state = {"solid":128,"liquid":129,"gas":130}[info.state];
if (state) { // instance of
lines.push("LAST\tP1\tQ"+state);
}
if (categories[info.category]) { // part of
lines.push("LAST\tP4\tQ"+categories[info.category]);
}
if (info.hidden) { // instance of
lines.push("LAST\tP1\tQ134");
}
if (id.startsWith("molten_")) { // instance of
lines.push("LAST\tP1\tQ573");
}
if (info.category === "tools" || info.tool) { // instance of
lines.push("LAST\tP1\tQ66");
}
lines.push("LAST\tDen\t\"Sandboxels element\"");
if (info.color) {
console.log("a")
if (Array.isArray(info.color)) {
for (var i = 0; i < info.color.length; i++) {
if (info.color[i].startsWith("#")) {
// add without #
lines.push("LAST\tP57\t\"" + info.color[i].substr(1) + "\"");
}
else {
// convert rgb(r,g,b) to hex
var rgb = info.color[i].replace(/rgb\(|\)/g, "").split(",");
var hex = "";
for (var j = 0; j < rgb.length; j++) {
var h = parseInt(rgb[j]).toString(16);
if (h.length < 2) {
h = "0" + h;
}
hex += h;
}
lines.push("LAST\tP57\t\"" + hex + "\"");
}
}
}
else {
if (info.color.startsWith("#")) {
// add without #
lines.push("LAST\tP57\t\"" + info.color.substr(1) + "\"");
}
else {
// convert rgb(r,g,b) to hex
var rgb = info.color.replace(/rgb\(|\)/g, "").split(",");
var hex = "";
for (var j = 0; j < rgb.length; j++) {
var h = parseInt(rgb[j]).toString(16);
if (h.length < 2) {
h = "0" + h;
}
hex += h;
}
lines.push("LAST\tP57\t\"" + hex + "\"");
}
}
}
}
console.log(lines.join("\n"));