4 * Copyright 2020 Elias Fleckenstein <eliasfleckenstein@web.de>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
24 dragonblocks.getSavestring = _ => {
25 dragonblocks.world.map = dragonblocks.map;
26 dragonblocks.world.mods = dragonblocks.mods;
27 dragonblocks.world.spawnedEntities = dblib.removeTmp(dragonblocks.spawnedEntities);
29 return JSON.stringify(dragonblocks.world);
32 dragonblocks.save = _ => {
33 if (dragonblocks.loggedin)
34 return dragonblocks.backendCall("saveWorld", true, {name: dragonblocks.worldname, world: dragonblocks.getSavestring()});
37 dragonblocks.checkWorldnameSpelling = name => {
38 return name.match(/^[a-zA-Z0-9]+$/);
41 dragonblocks.loadWorldList = _ => {
42 dragonblocks.worlds = dragonblocks.backendCall("getWorlds");
45 dragonblocks.getEmptyWorld = function(){
48 data: Array(dragonblocks.settings.map.width).fill(Array(dragonblocks.settings.map.width).fill(new dragonblocks.MapNode("air"))),
49 width: dragonblocks.settings.map.width,
50 height: dragonblocks.settings.map.height,
51 displayTop: dragonblocks.settings.map.height / 2,
52 displayLeft: dragonblocks.settings.map.width / 2 - 5,