Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var default_entity_stats = [];
- var default_action_stats = [];
- var entityLayers = [];
- var entityRoster = [];
- var actionRoster = [];
- var full_entity_stats = [];
- var full_map = [];
- loadDefaultEntities();
- loadDefaultActions();
- function loadDefaultEntities() {
- try {
- // Load entity layers and default stats
- entityLayers = loadJSONDirect('/test dictionary/scripts/json/gamevars/entityRoster.json');
- default_entity_stats['____'] = loadJSONDirect('/test dictionary/scripts/json/gamevars/default stats.json');
- // Iterate over entity layers
- for (let layer = 0; layer < entityLayers.length; layer++) {
- entityRoster = entityLayers[layer];
- for (let index = 0; index < entityRoster.length; index++) {
- const entityName = entityRoster[index];
- const entityShortName = entityName.substring(0, 4);
- const filePath = `/test dictionary/scripts/json/gamevars/entities/${entityShortName}.json`;
- // Load entity stats
- const entityStats = loadJSONDirect(filePath);
- if (entityStats && entityStats[entityShortName]) {
- if (!default_entity_stats[entityName]) {
- default_entity_stats[entityName] = {};
- }
- default_entity_stats[entityName].stats = entityStats[entityShortName].stats;
- }
- }
- }
- } catch (error) {
- console.error('Error loading default entities:', error);
- }
- }
- function loadDefaultActions() {
- try {
- // Load action roster
- actionRoster = loadJSONDirect('/test dictionary/scripts/json/gamevars/actionRoster.json');
- for (let index = 0; index < actionRoster.length; index++) {
- const actionName = actionRoster[index];
- const actionShortName = actionName.substring(0, 4);
- const url = `/test dictionary/scripts/json/gamevars/actions/${actionShortName}.json`;
- // Load action stats
- const actionStats = loadJSONDirect(url);
- if (actionStats) {
- default_action_stats[actionShortName] = actionStats;
- }
- }
- } catch (error) {
- console.error('Error loading default actions:', error);
- }
- }
- function loadMap() {
- try {
- // Load the raw map data
- const rawMap = loadJSONDirect('/test dictionary/scripts/json/maps/demo.json');
- full_map = create3DArrayBlock('____', 0, rawMap.length - 1, 0, rawMap[0].length - 1, 0, layers.gui);
- full_entity_stats = create3DArrayBlock([], 0, rawMap.length - 1, 0, rawMap[0].length - 1, 0, layers.gui);
- for (let y = 0; y < rawMap[0].length; y++) {
- for (let x = 0; x < rawMap.length; x++) {
- for (let z = 0; z < layers.gui; z++) {
- const mapCell = rawMap[x][y][z];
- const mapCellShortName = mapCell.substring(0, 4);
- full_map[x][y][z] = mapCellShortName;
- if (default_entity_stats[mapCellShortName]) {
- full_entity_stats[x][y][z] = default_entity_stats[mapCellShortName];
- } else {
- full_entity_stats[x][y][z] = default_entity_stats['____'];
- }
- }
- }
- }
- cx = randInt(0, full_map.length - 1);
- cy = randInt(0, full_map[0].length - 1);
- } catch (error) {
- console.error('Error loading map:', error);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement