Fix: Getting rid of duplicate minetest.register_on_joinplayer.
parent
e8796f3a18
commit
a0caf808e0
|
@ -210,47 +210,4 @@ function minetest_wadsprint.load_players_stats()
|
||||||
minetest_wadsprint.offline_stats[val.name] = { stamina = val.stamina }
|
minetest_wadsprint.offline_stats[val.name] = { stamina = val.stamina }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
----------------------------------------------------------------------------------------------------
|
|
||||||
------------------------------------------------------------------------------ Mod initialization --
|
|
||||||
----------------------------------------------------------------------------------------------------
|
|
||||||
minetest.register_on_joinplayer(minetest_wadsprint.initialize_player)
|
|
||||||
minetest.register_on_respawnplayer(minetest_wadsprint.reset_player_stats)
|
|
||||||
minetest.register_on_leaveplayer(minetest_wadsprint.deinitialize_player)
|
|
||||||
|
|
||||||
-- Register hudbar call for compatibility with some hudbar mods.
|
|
||||||
if minetest_wadsprint.register_hudbar ~= nil then
|
|
||||||
minetest_wadsprint.register_hudbar()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Save player stats to file on server shutdown.
|
|
||||||
if minetest_wadsprint.SAVE_PLAYERS_STATS_TO_FILE then
|
|
||||||
minetest_wadsprint.load_players_stats()
|
|
||||||
minetest.register_on_shutdown(minetest_wadsprint.save_players_stats)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Main cycle.
|
|
||||||
local timer_of_stats_update = 0
|
|
||||||
local timer_of_controls_check = 0
|
|
||||||
minetest.register_globalstep(function(seconds_since_last_global_step) -- Called every server step, usually interval of 0.05s.
|
|
||||||
|
|
||||||
timer_of_stats_update = timer_of_stats_update + seconds_since_last_global_step
|
|
||||||
timer_of_controls_check = timer_of_controls_check + seconds_since_last_global_step
|
|
||||||
|
|
||||||
-- Run stamina update cycle for every player.
|
|
||||||
if timer_of_stats_update > minetest_wadsprint.PLAYER_STATS_UPDATE_PERIOD_SECONDS then
|
|
||||||
timer_of_stats_update = 0
|
|
||||||
for player_name,player in pairs(minetest_wadsprint.stats) do
|
|
||||||
minetest_wadsprint.stamina_update_cycle_tick(player)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Scan players controls.
|
|
||||||
if timer_of_controls_check > minetest_wadsprint.PLAYER_CONTROLS_CHECK_PERIOD_SECONDS then
|
|
||||||
timer_of_controls_check = 0
|
|
||||||
for player_name,player in pairs(minetest_wadsprint.stats) do
|
|
||||||
minetest_wadsprint.scan_player_controls(player)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end)
|
|
45
init.lua
45
init.lua
|
@ -33,4 +33,47 @@ dofile(minetest.get_modpath(minetest.get_current_modname()).."/init.core.lua")
|
||||||
dofile(minetest.get_modpath(minetest.get_current_modname()).."/init.legacy.lua")
|
dofile(minetest.get_modpath(minetest.get_current_modname()).."/init.legacy.lua")
|
||||||
dofile(minetest.get_modpath(minetest.get_current_modname()).."/init.config.lua")
|
dofile(minetest.get_modpath(minetest.get_current_modname()).."/init.config.lua")
|
||||||
dofile(minetest.get_modpath(minetest.get_current_modname()).."/init.hudbars.lua")
|
dofile(minetest.get_modpath(minetest.get_current_modname()).."/init.hudbars.lua")
|
||||||
dofile(minetest.get_modpath(minetest.get_current_modname()).."/init.set_sprinting_physics.lua")
|
dofile(minetest.get_modpath(minetest.get_current_modname()).."/init.set_sprinting_physics.lua")
|
||||||
|
----------------------------------------------------------------------------------------------------
|
||||||
|
------------------------------------------------------------------------------ Mod initialization --
|
||||||
|
----------------------------------------------------------------------------------------------------
|
||||||
|
minetest.register_on_joinplayer(minetest_wadsprint.initialize_player)
|
||||||
|
minetest.register_on_respawnplayer(minetest_wadsprint.reset_player_stats)
|
||||||
|
minetest.register_on_leaveplayer(minetest_wadsprint.deinitialize_player)
|
||||||
|
|
||||||
|
-- Register hudbar call for compatibility with some hudbar mods.
|
||||||
|
if minetest_wadsprint.register_hudbar ~= nil then
|
||||||
|
minetest_wadsprint.register_hudbar()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Save player stats to file on server shutdown.
|
||||||
|
if minetest_wadsprint.SAVE_PLAYERS_STATS_TO_FILE then
|
||||||
|
minetest_wadsprint.load_players_stats()
|
||||||
|
minetest.register_on_shutdown(minetest_wadsprint.save_players_stats)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Main cycle.
|
||||||
|
local timer_of_stats_update = 0
|
||||||
|
local timer_of_controls_check = 0
|
||||||
|
minetest.register_globalstep(function(seconds_since_last_global_step) -- Called every server step, usually interval of 0.05s.
|
||||||
|
|
||||||
|
timer_of_stats_update = timer_of_stats_update + seconds_since_last_global_step
|
||||||
|
timer_of_controls_check = timer_of_controls_check + seconds_since_last_global_step
|
||||||
|
|
||||||
|
-- Run stamina update cycle for every player.
|
||||||
|
if timer_of_stats_update > minetest_wadsprint.PLAYER_STATS_UPDATE_PERIOD_SECONDS then
|
||||||
|
timer_of_stats_update = 0
|
||||||
|
for player_name,player in pairs(minetest_wadsprint.stats) do
|
||||||
|
minetest_wadsprint.stamina_update_cycle_tick(player)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Scan players controls.
|
||||||
|
if timer_of_controls_check > minetest_wadsprint.PLAYER_CONTROLS_CHECK_PERIOD_SECONDS then
|
||||||
|
timer_of_controls_check = 0
|
||||||
|
for player_name,player in pairs(minetest_wadsprint.stats) do
|
||||||
|
minetest_wadsprint.scan_player_controls(player)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end)
|
|
@ -21,11 +21,13 @@ if minetest_wadsprint.BAD_PHYSICS_OVERRIDE_MODE == true then
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif minetest.get_modpath("player_monoids") ~= nil then
|
elseif minetest.get_modpath("player_monoids") ~= nil then
|
||||||
minetest.register_on_joinplayer(function(player_obj)
|
local default_minetest_wadsprint_initialize_player = minetest_wadsprint.initialize_player
|
||||||
minetest_wadsprint.stats[player_obj:get_player_name()].monoids = {}
|
function minetest_wadsprint.initialize_player(player_obj)
|
||||||
minetest_wadsprint.stats[player_obj:get_player_name()].monoids.jump = {}
|
default_minetest_wadsprint_initialize_player(player_obj)
|
||||||
minetest_wadsprint.stats[player_obj:get_player_name()].monoids.speed = {}
|
minetest_wadsprint.stats[player_obj:get_player_name()].monoids = {}
|
||||||
end)
|
minetest_wadsprint.stats[player_obj:get_player_name()].monoids.jump = {}
|
||||||
|
minetest_wadsprint.stats[player_obj:get_player_name()].monoids.speed = {}
|
||||||
|
end
|
||||||
function minetest_wadsprint.set_sprinting_physics(player,is_on_val)
|
function minetest_wadsprint.set_sprinting_physics(player,is_on_val)
|
||||||
if player.is_sprinting_physics_on ~= is_on_val then
|
if player.is_sprinting_physics_on ~= is_on_val then
|
||||||
if is_on_val == true then
|
if is_on_val == true then
|
||||||
|
|
BIN
util/version.png
BIN
util/version.png
Binary file not shown.
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
Loading…
Reference in New Issue