Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- async function loadFullMap() {
- // Load the full map
- const full_map = await fetch(`http://${host}/maps/roe2a/${map}.json`).then(response => response.json());
- // Initialize full_stats array
- const full_stats = [];
- for (let x = 0; x < full_map.length; x++) {
- full_stats[x] = []; // Initialize the second dimension
- for (let y = 0; y < full_map[x].length; y++) {
- full_stats[x][y] = []; // Initialize the third dimension
- for (let z = 0; z < gui; z++) {
- const sectionValue = section(full_map[x][y][z], 0);
- const url = `http://${host}/entity dictionary/json/${sectionValue}.json`;
- // Check if the file exists before fetching it
- if (await fileExists(url)) {
- full_stats[x][y][z] = await fetch(url).then(response => response.json());
- } else {
- // console.warn(`File not found: ${url}`);
- full_stats[x][y][z] = null; // or handle the missing file case as needed
- continue;
- }
- // Capture the first key
- const keys = Object.keys(full_stats[x][y][z]);
- if (keys.length === 0) {
- full_stats[x][y][z] = null;
- continue;
- }
- const key = keys[0];
- if ( key === section( full_map[x][y][z], 0 ) ){
- console.log( { key: key, x: x, y: y, z: z } );
- // Render the actions
- full_stats[x][y][z] = full_stats[x][y][z][key];
- }
- }
- }
- }
- return full_stats;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement