Browse Source

ghost then later hide players if not moving

and update readme
master
poikilos 9 years ago
committed by Jacob Gustafson
parent
commit
618357f442
  1. 9
      README.md
  2. 30
      web/chunkymap.php

9
README.md

@ -10,6 +10,10 @@ This program comes without any warranty, to the extent permitted by applicable l
* Has static html version of map (echo_chunkymap_table() php function) * Has static html version of map (echo_chunkymap_table() php function)
* Zoom in and out * Zoom in and out
* optionally echo name of world that was detected by the scheduled py file * optionally echo name of world that was detected by the scheduled py file
* shows player location (and only first 2 characters of name, for privacy; there is no saved setting yet, so to adjust, you must change the value of $nonprivate_name_beginning_char_count in chunkymap.php)
* Ghost players if they stay in one spot 2 minutes (consider them logged out by that method alone since not requiring mods; see $player_file_age_idle_max_seconds in chunkymap.php)
* Hide players if they stay in one spot 5 minutes (consider them logged out by that method alone since not requiring mods; see $player_file_age_expired_max_seconds in chunkymap.php)
* Has optional script to add crontab entry (to schedule update script every minute that runs the py file unless the py file is not complete [took longer than 1 minute]) * Has optional script to add crontab entry (to schedule update script every minute that runs the py file unless the py file is not complete [took longer than 1 minute])
## Requirements: ## Requirements:
@ -58,7 +62,6 @@ This program comes without any warranty, to the extent permitted by applicable l
## Known Issues ## Known Issues
* index-example.php should read the size of the chunks -- see near is_file($chunk_genresult_path) in chunkymap.php * index-example.php should read the size of the chunks -- see near is_file($chunk_genresult_path) in chunkymap.php
* Show player location (and optionally turn off) * optionally hide player location
* Make a php file that shows the map on an html5 canvas (refresh players every 10 seconds, check for new map chunks every minute) * Make a method (in chunkymap.php) to echo the map as an html5 canvas (refresh players every 10 seconds, check for new map chunks every minute)
* Make players invisible if they stay in one spot too long (consider them logged out by that method alone since not requiring mods)
* Detect failure of minetestmapper-numpy.py and instead use minetest-mapper if on linux, otherwise show error if neither are present (Windows has no minetest-mapper at least on client 0.4.13) * Detect failure of minetestmapper-numpy.py and instead use minetest-mapper if on linux, otherwise show error if neither are present (Windows has no minetest-mapper at least on client 0.4.13)

30
web/chunkymap.php

@ -310,6 +310,7 @@ function echo_chunkymap_table() {
$chunk_assoc[$chunk_luid][ "players" ][ $chunk_assoc[$chunk_luid]["players_count"] ][ "z" ] = $player_dict["z"]; $chunk_assoc[$chunk_luid][ "players" ][ $chunk_assoc[$chunk_luid]["players_count"] ][ "z" ] = $player_dict["z"];
$chunk_assoc[$chunk_luid][ "players" ][ $chunk_assoc[$chunk_luid]["players_count"] ][ "rel_x" ] = $rel_x; $chunk_assoc[$chunk_luid][ "players" ][ $chunk_assoc[$chunk_luid]["players_count"] ][ "rel_x" ] = $rel_x;
$chunk_assoc[$chunk_luid][ "players" ][ $chunk_assoc[$chunk_luid]["players_count"] ][ "rel_z" ] = $rel_z; $chunk_assoc[$chunk_luid][ "players" ][ $chunk_assoc[$chunk_luid]["players_count"] ][ "rel_z" ] = $rel_z;
$chunk_assoc[$chunk_luid][ "players" ][ $chunk_assoc[$chunk_luid]["players_count"] ][ "file_path" ] = $file_path;
if (isset($player_dict["name"])) { if (isset($player_dict["name"])) {
$chunk_assoc[$chunk_luid][ "players" ][ $chunk_assoc[$chunk_luid]["players_count"] ][ "name" ] = $player_dict["name"]; $chunk_assoc[$chunk_luid][ "players" ][ $chunk_assoc[$chunk_luid]["players_count"] ][ "name" ] = $player_dict["name"];
@ -396,6 +397,8 @@ function echo_chunkymap_table() {
$zoomed_h=(int)((float)$chunkymap_tile_original_h*$scale+.5); $zoomed_h=(int)((float)$chunkymap_tile_original_h*$scale+.5);
$genresult_suffix_then_dot_then_ext="_mapper_result.txt"; $genresult_suffix_then_dot_then_ext="_mapper_result.txt";
$dot_yaml=".yml"; $dot_yaml=".yml";
$player_file_age_expired_max_seconds=299;
$player_file_age_idle_max_seconds=119;
while ($z >= $chunkz_min) { while ($z >= $chunkz_min) {
echo_hold( " <tr>\r\n"); echo_hold( " <tr>\r\n");
$x = (int)$chunkx_min; $x = (int)$chunkx_min;
@ -448,14 +451,14 @@ function echo_chunkymap_table() {
if (isset($chunk_dict["image_right"])) { if (isset($chunk_dict["image_right"])) {
if ( (int)$chunk_dict["image_left"] > $expected_left ) { if ( (int)$chunk_dict["image_left"] > $expected_left ) {
$td_style_suffix.="text-align:right;"; $td_style_suffix.="text-align:right;";
$alignment_comment.="<!-- image_left:".$chunk_dict["image_left"]." is greater than expected $expected_left-->"; //$alignment_comment.="<!-- image_left:".$chunk_dict["image_left"]." is greater than expected $expected_left-->";
} }
//elseif ( (int)$chunk_dict["image_right"] < $expected_right ) { //elseif ( (int)$chunk_dict["image_right"] < $expected_right ) {
// $td_style_suffix.="text-align:left;"; // $td_style_suffix.="text-align:left;";
//} //}
else { else {
$td_style_suffix.="text-align:left;"; $td_style_suffix.="text-align:left;";
$alignment_comment.="<!-- image_left:".$chunk_dict["image_left"]." was the expected $expected_left-->"; //$alignment_comment.="<!-- image_left:".$chunk_dict["image_left"]." was the expected $expected_left-->";
} }
} }
} }
@ -473,14 +476,14 @@ function echo_chunkymap_table() {
if (isset($chunk_dict["image_bottom"])) { if (isset($chunk_dict["image_bottom"])) {
if ( (int)$chunk_dict["image_top"] > $expected_top) { if ( (int)$chunk_dict["image_top"] > $expected_top) {
$element_align_style_suffix.="vertical-align:bottom;"; $element_align_style_suffix.="vertical-align:bottom;";
$alignment_comment.="<!-- image_top:".$chunk_dict["image_top"]." is greater than expected $expected_top-->"; //$alignment_comment.="<!-- image_top:".$chunk_dict["image_top"]." is greater than expected $expected_top-->";
} }
//elseif ( (int)$chunk_dict["image_bottom"] < $expected_bottom) { //elseif ( (int)$chunk_dict["image_bottom"] < $expected_bottom) {
// $element_align_style_suffix.="vertical-align:top;"; // $element_align_style_suffix.="vertical-align:top;";
//} //}
else { else {
$element_align_style_suffix.="vertical-align:top;"; $element_align_style_suffix.="vertical-align:top;";
$alignment_comment.="<!-- image_top:".$chunk_dict["image_top"]." was the expected $expected_top-->"; //$alignment_comment.="<!-- image_top:".$chunk_dict["image_top"]." was the expected $expected_top-->";
} }
} }
} }
@ -518,6 +521,17 @@ function echo_chunkymap_table() {
for ($player_count=0; $player_count<$chunk_assoc[$chunk_luid]["players_count"]; $player_count++) { for ($player_count=0; $player_count<$chunk_assoc[$chunk_luid]["players_count"]; $player_count++) {
$rel_x = $chunk_assoc[$chunk_luid][ "players" ][ $player_count ]["rel_x"]; $rel_x = $chunk_assoc[$chunk_luid][ "players" ][ $player_count ]["rel_x"];
$rel_z = $chunk_assoc[$chunk_luid][ "players" ][ $player_count ]["rel_z"]; $rel_z = $chunk_assoc[$chunk_luid][ "players" ][ $player_count ]["rel_z"];
$is_expired=false;
$is_idle=false;
if (isset($chunk_assoc[$chunk_luid][ "players" ][ $player_count ]["file_path"])) {
$last_player_update_time=filemtime($chunk_assoc[$chunk_luid][ "players" ][ $player_count ]["file_path"]);
if (time()-$last_player_update_time > $player_file_age_expired_max_seconds) {
$is_expired=true;
}
elseif (time()-$last_player_update_time > $player_file_age_idle_max_seconds) {
$is_idle=true;
}
}
$player_name = $chunk_assoc[$chunk_luid]["players"][$player_count]["name"]; $player_name = $chunk_assoc[$chunk_luid]["players"][$player_count]["name"];
if (strlen($chunk_assoc[$chunk_luid]["players"][$player_count]["name"])>$nonprivate_name_beginning_char_count) { if (strlen($chunk_assoc[$chunk_luid]["players"][$player_count]["name"])>$nonprivate_name_beginning_char_count) {
$player_name = substr($player_name, 0, $nonprivate_name_beginning_char_count)."*"; $player_name = substr($player_name, 0, $nonprivate_name_beginning_char_count)."*";
@ -527,7 +541,13 @@ function echo_chunkymap_table() {
$zoomed_head_h=$character_icon_h;//(int)((float)$character_icon_h*$scale+.5); $zoomed_head_h=$character_icon_h;//(int)((float)$character_icon_h*$scale+.5);
$rel_x -= (int)($zoomed_head_w/2); $rel_x -= (int)($zoomed_head_w/2);
$rel_z -= (int)($zoomed_head_h/2); $rel_z -= (int)($zoomed_head_h/2);
echo_hold( "<div style=\"position:absolute; left:$rel_x; top:$rel_z; width: $zoomed_head_w; height: $zoomed_head_h; border: 1px solid white\"><img src=\"images/chunkymap_character-face.png\"/>$player_name</div>" ); $img_style="";
if (!$is_expired) {
if ($is_idle) {
$img_style="opacity: 0.4; filter: alpha(opacity=40);"; //filter is for IE8 and below
}
echo_hold( "<div style=\"position:absolute; left:$rel_x; top:$rel_z; width: $zoomed_head_w; height: $zoomed_head_h; border: 1px solid white\"><img src=\"images/chunkymap_character-face.png\" style=\"$img_style\"/>$player_name</div>" );
}
//$position_offset_x+=$character_icon_w; //$position_offset_x+=$character_icon_w;
} }
} }

Loading…
Cancel
Save