Merge branch 'amidstExport'
This commit is contained in:
commit
f5a041f42d
@ -161,8 +161,9 @@ A Voronoi diagram is supposed to be here but for some reason it cannot be displa
|
|||||||
<div class="configFrame" id="exportContainer" style="display:none">
|
<div class="configFrame" id="exportContainer" style="display:none">
|
||||||
<form id="exportForm">
|
<form id="exportForm">
|
||||||
<div>
|
<div>
|
||||||
<button id="inputExportLua" type="button">Export Lua</button>
|
<button id="inputExportLua" type="button">Export as Lua</button>
|
||||||
<button id="inputExportJSON" type="button">Export JSON</button>
|
<button id="inputExportJSON" type="button">Export as JSON</button>
|
||||||
|
<button id="inputExportAmidstForMinetest" type="button">Export as Amidst for Minetest biome profile</button>
|
||||||
<button id="inputExportClear" type="button">Clear</button>
|
<button id="inputExportClear" type="button">Clear</button>
|
||||||
</div>
|
</div>
|
||||||
<div id="exportSectionOuter" hidden><br><span id="exportLabel"></span>
|
<div id="exportSectionOuter" hidden><br><span id="exportLabel"></span>
|
||||||
|
@ -80,9 +80,11 @@
|
|||||||
<h3>Export</h3>
|
<h3>Export</h3>
|
||||||
<p>This allows you to export the current biomes into a text. You can choose to export them either to Lua code or JSON. The export only includes the basic biome info but not stuff like biome color (which is only relevant for MiBPoV) or noise parameters.</p>
|
<p>This allows you to export the current biomes into a text. You can choose to export them either to Lua code or JSON. The export only includes the basic biome info but not stuff like biome color (which is only relevant for MiBPoV) or noise parameters.</p>
|
||||||
|
|
||||||
<p>The Lua export gives you a very basic Lua code that can be pasted into an actual Lua mod. The code is very basic and does not include the “landscape materials”, like what the surface is made of (dirt, stone, sand, etc.).</p>
|
<p>The <i>Lua</i> export gives you a very basic Lua code that can be pasted into an actual Lua mod. The code is very basic and does not include the “landscape materials”, like what the surface is made of (dirt, stone, sand, etc.).</p>
|
||||||
|
|
||||||
<p>The JSON export is a text you can use to import later. You could save this in a text file so you can import it later.</p>
|
<p>The <i>JSON</i> export is a text you can use to import later. You could save this in a text file so you can import it later.</p>
|
||||||
|
|
||||||
|
<p>The <i>Amidst for Minetest</i> export gives you a biome profile you can use for <a href="https://github.com/Treer/Amidst-for-Minetest">Amidst for Minetest</a>.</p>
|
||||||
|
|
||||||
<p>The “Clear” button clears the previous export. This is just there to reduce clutter on the webpage.</p>
|
<p>The “Clear” button clears the previous export. This is just there to reduce clutter on the webpage.</p>
|
||||||
|
|
||||||
|
58
mibpov.js
58
mibpov.js
@ -71,6 +71,8 @@ const AXIS_COLOR = "#000000";
|
|||||||
// Color to be used when the diagram is cleared
|
// Color to be used when the diagram is cleared
|
||||||
const CLEAR_COLOR = "#ecddba";
|
const CLEAR_COLOR = "#ecddba";
|
||||||
// list of possible cell colors
|
// list of possible cell colors
|
||||||
|
// note: These MUST be in "#xxxxxx" format
|
||||||
|
// for the hexColorToRGBColor function to work.
|
||||||
const CELL_COLORS = [
|
const CELL_COLORS = [
|
||||||
"#64988e",
|
"#64988e",
|
||||||
"#3d7085",
|
"#3d7085",
|
||||||
@ -1794,6 +1796,62 @@ inputExportJSON.onclick = function() {
|
|||||||
}
|
}
|
||||||
exportSectionOuter.hidden = false;
|
exportSectionOuter.hidden = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Assuming that hexColor is a string of the form
|
||||||
|
// "#xxxxxx" (where x is a hexadecimal digit),
|
||||||
|
// returns an object of the form { r: 0, g: 0, b: 0 }
|
||||||
|
function hexColorToRGBColor(hexColor) {
|
||||||
|
if (typeof hexColor !== "string") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
let rh = hexColor.slice(1,3);
|
||||||
|
let gh = hexColor.slice(3,5);
|
||||||
|
let bh = hexColor.slice(5,7);
|
||||||
|
if (rh === "" || gh === "" || bh === "") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
let r = Number("0x"+rh)
|
||||||
|
let g = Number("0x"+gh)
|
||||||
|
let b = Number("0x"+bh)
|
||||||
|
if (typeof r !== "number" || typeof g !== "number" || typeof b !== "number") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return { r:r, g:g, b:b }
|
||||||
|
}
|
||||||
|
|
||||||
|
inputExportAmidstForMinetest.onclick = function() {
|
||||||
|
let jsonOut = {};
|
||||||
|
jsonOut.name = "MiBPoV Export";
|
||||||
|
let jsonPoints = [];
|
||||||
|
for (let b=0; b<biomePoints.length; b++) {
|
||||||
|
let biome = biomePoints[b];
|
||||||
|
let jsonPoint = {};
|
||||||
|
jsonPoint.name = biome.name;
|
||||||
|
let color = hexColorToRGBColor(CELL_COLORS[biome.colorIndex]);
|
||||||
|
if (color !== null) {
|
||||||
|
jsonPoint.color = color;
|
||||||
|
} else {
|
||||||
|
jsonPoint.color = { r: 255, g: 255, b: 255 };
|
||||||
|
}
|
||||||
|
jsonPoint.y_min = biome.min_y;
|
||||||
|
jsonPoint.y_max = biome.max_y;
|
||||||
|
jsonPoint.heat_point = biome.heat;
|
||||||
|
jsonPoint.humidity_point = biome.humidity;
|
||||||
|
jsonPoints.push(jsonPoint);
|
||||||
|
}
|
||||||
|
jsonOut.biomeList = jsonPoints;
|
||||||
|
|
||||||
|
let str = JSON.stringify(jsonOut, undefined, 4);
|
||||||
|
exportSectionText.innerText = str;
|
||||||
|
if (str === "") {
|
||||||
|
exportSectionText.hidden = true;
|
||||||
|
exportLabel.innerText = "Export is empty.";
|
||||||
|
} else {
|
||||||
|
exportSectionText.hidden = false;
|
||||||
|
exportLabel.innerText = "Exported biomes (as Amidst for Minetest biome profile):";
|
||||||
|
}
|
||||||
|
exportSectionOuter.hidden = false;
|
||||||
|
}
|
||||||
inputExportClear.onclick = function() {
|
inputExportClear.onclick = function() {
|
||||||
exportSectionOuter.hidden = true;
|
exportSectionOuter.hidden = true;
|
||||||
exportSectionText.innerText = "";
|
exportSectionText.innerText = "";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user