forked from mtcontrib/leaftest
Allow set most params in .sh via env. Allow change tilesize and tiles dir.
This commit is contained in:
parent
a470106c84
commit
0d15c3a66c
29
mapper.sh
29
mapper.sh
@ -3,12 +3,11 @@
|
||||
MAPDIR=$1
|
||||
SPAWNPOS=$2
|
||||
DIMENSIONS=$3
|
||||
DIMENSIONS=${DIMENSIONS=6144}
|
||||
|
||||
if [ -z $MAPPERDIR ]; then
|
||||
MAPPERDIR=.
|
||||
fi
|
||||
MAPPERDIR=${MAPPERDIR=.}
|
||||
|
||||
mapperpath=$MAPPERDIR/minetestmapper
|
||||
mapperpath=${mapperpath=$MAPPERDIR/minetestmapper}
|
||||
|
||||
if [ ! -f $mapperpath ]; then
|
||||
echo "Error, "$mapperpath" doesn't exist."
|
||||
@ -35,9 +34,7 @@ else
|
||||
}
|
||||
fi
|
||||
|
||||
if [ -z "$JOBNUM" ]; then
|
||||
JOBNUM=1
|
||||
fi
|
||||
JOBNUM=${JOBNUM=1}
|
||||
|
||||
case "$JOBNUM" in
|
||||
''|*[!0-9]*) echo "Bad number of jobs '$JOBNUM'. Please specify a positive integer." ; exit 1 ;;
|
||||
@ -66,16 +63,20 @@ eval $prefix_func
|
||||
#bash -c "$prefix_pipefail ; (echo -e 'a\nb\nc\n' ; false) | prefix 'PREF '" || echo "ERR"
|
||||
#exit 1
|
||||
|
||||
scriptdir=`readlink -f $0`
|
||||
scriptdir=`dirname $scriptdir`
|
||||
if [ -z "$scriptdir" ]; then
|
||||
scriptdir=`readlink -f $0`
|
||||
scriptdir=`dirname $scriptdir`
|
||||
fi
|
||||
|
||||
tiledir=$scriptdir/www/tiles
|
||||
tiledir=${tiledir=$scriptdir/www/tiles}
|
||||
|
||||
spawnx=${SPAWNPOS%%,*}
|
||||
spawnx=${spawnx=0}
|
||||
spawny=${SPAWNPOS##*,}
|
||||
spawny=${spawny=0}
|
||||
#echo "spawn position: $spawnx $spawny"
|
||||
tilesize=256
|
||||
zoomlevelnum=3
|
||||
tilesize=${tilesize=256}
|
||||
zoomlevelnum=${zoomlevelnum=3}
|
||||
|
||||
tilenum=$(($DIMENSIONS/$tilesize))
|
||||
|
||||
@ -121,7 +122,7 @@ do
|
||||
dir=$tiledir/$zoomlevel
|
||||
dirb=$tiledir/$zoomlevelbefore
|
||||
mkdir -p $dir
|
||||
rm -f ${dir}/20/*
|
||||
rm -f ${dir}/*
|
||||
for x in $(seq 0 $tnum)
|
||||
do
|
||||
for y in $(seq 0 $tnum)
|
||||
@ -144,4 +145,4 @@ done
|
||||
|
||||
zoommin=$((20-$zoomlevelnum))
|
||||
#write the resulting config into a json file
|
||||
echo "{\"mapsize\":$DIMENSIONS, \"spawn\":{\"x\":$spawnx,\"y\":$spawny}, \"zoommin\":$zoommin}" > $scriptdir/www/conf.json
|
||||
echo "{\"mapsize\":$DIMENSIONS, \"spawn\":{\"x\":$spawnx,\"y\":$spawny}, \"zoommin\":$zoommin, \"tilesize\":$tilesize}" > ${conffile=$tiledir/conf.json}
|
||||
|
10
www/map.js
10
www/map.js
@ -1,3 +1,4 @@
|
||||
var tilesdir = 'tiles/';
|
||||
var xmlhttp = new XMLHttpRequest();
|
||||
xmlhttp.onreadystatechange = function() {
|
||||
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
||||
@ -5,7 +6,7 @@ xmlhttp.onreadystatechange = function() {
|
||||
loadmap(config);
|
||||
}
|
||||
}
|
||||
xmlhttp.open("GET", "conf.json", true);
|
||||
xmlhttp.open("GET", tilesdir + "conf.json", true);
|
||||
xmlhttp.overrideMimeType("application/json"); //to silence browser warnings when started without a server
|
||||
xmlhttp.send();
|
||||
|
||||
@ -13,8 +14,9 @@ function loadmap(config) {
|
||||
var mapsize = config.mapsize;
|
||||
var spawn = config.spawn;
|
||||
var zoommin = config.zoommin;
|
||||
var tilesize = config.tilesize;
|
||||
var xb= 0-spawn.x+mapsize/2;
|
||||
var yb= 0-spawn.y-mapsize/2-256;
|
||||
var yb= 0-spawn.y-mapsize/2-tilesize;
|
||||
var bnd = new L.LatLngBounds();
|
||||
bnd.extend(L.latLng([spawn.x-mapsize/2, spawn.y-mapsize/2]));
|
||||
bnd.extend(L.latLng([spawn.x+mapsize/2, spawn.y+mapsize/2]));
|
||||
@ -41,10 +43,10 @@ function loadmap(config) {
|
||||
})
|
||||
}).setView([0,0], 22);
|
||||
map.setView([spawn.x,spawn.y]);
|
||||
L.tileLayer('tiles/{z}/map_{x}_{y}.png', {
|
||||
L.tileLayer(tilesdir + '{z}/map_{x}_{y}.png', {
|
||||
maxZoom: 26,
|
||||
maxNativeZoom: 20,
|
||||
tileSize: 256,
|
||||
tileSize: tilesize,
|
||||
continuousWorld: true
|
||||
}).addTo(map);
|
||||
map.on('mousemove click', function(e) {
|
||||
|
Loading…
Reference in New Issue
Block a user