- initial beta version
master
Leslie Krause 2020-08-30 17:57:00 -04:00
commit 8edea73845
4 changed files with 104 additions and 0 deletions

47
README.txt Normal file
View File

@ -0,0 +1,47 @@
Player Coords Mod v1.0
By Leslie Krause
Player Coords is an esy-to-use debugging tool for game developers to record player
movement via a dedicated log file. It is intended for singleplayer, but can also prove
useful in multiplayer (the "server" privilege is required).
The results are output to the "coords.txt" file in the world directory. Hence, you can
use the "tail -f" command to observe player movement from a secondary terminal window.
Compatability
----------------------
Minetest 0.4.15+ required
Installation
----------------------
1) Unzip the archive into the mods directory of your game.
2) Rename the player_coords-master directory to "player_coords".
Source Code License
----------------------
The MIT License (MIT)
Copyright (c) 2020, Leslie E. Krause (leslie@searstower.org)
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
For more details:
https://opensource.org/licenses/MIT

0
depends.txt Normal file
View File

53
init.lua Normal file
View File

@ -0,0 +1,53 @@
--------------------------------------------------------
-- Minetest :: Player Coords Mod (player_coords)
--
-- See README.txt for licensing and release notes.
-- Copyright (c) 2020, Leslie E. Krause
--
-- ./games/minetest_game/mods/player_coords/init.lua
--------------------------------------------------------
local track_player
local log_file
local last_pos
local last_dir
minetest.register_on_joinplayer( function ( player )
local player_name = player:get_player_name( )
if player_name == "singleplayer" or minetest.check_player_privs( player_name, "server" ) then
log_file = io.open( minetest.get_worldpath( ) .. "/coords.txt", "w" )
if log_file then
track_player = player
last_pos = player:get_pos( )
last_dir = vector.new( )
end
end
end )
minetest.register_on_leaveplayer( function ( player )
if log_file then
log_file:close( )
track_player = nil
end
end )
minetest.register_on_shutdown( function ( )
if log_file then log_file:close( ) end
end )
minetest.register_globalstep( function( dtime )
if track_player then
local pos = track_player:get_pos( )
local dir = vector.direction( last_pos, pos )
if math.abs( last_dir.x - dir.x ) > 0.1 or math.abs( last_dir.y - dir.y ) > 0.1 or math.abs( last_dir.z - dir.z ) > 0.1 then
log_file:write( minetest.pos_to_string( last_pos ) .. "\n" )
log_file:flush( )
last_dir = dir
end
last_pos = pos
end
end )

4
mod.conf Normal file
View File

@ -0,0 +1,4 @@
name = player_coords
title = Player Coords
author = sorcerykid
license = MIT