1
0
mirror of https://github.com/minetest-mods/3d_armor.git synced 2024-12-27 11:10:39 +01:00

init-cleanup (#115)

Co-authored-by: BuckarooBanzay <BuckarooBanzay@users.noreply.github.com>
This commit is contained in:
Buckaroo Banzai 2023-10-26 10:39:55 +02:00 committed by GitHub
parent c894ba4b0c
commit 3660e50312
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 5 additions and 52 deletions

View File

@ -6,7 +6,7 @@
|-[Armor Configuration](#armor-configuration) |||- - [3d_Armor Item Storage](#3d_armor-item-storage) |-[Armor Configuration](#armor-configuration) |||- - [3d_Armor Item Storage](#3d_armor-item-storage)
|- - [disable_specific_materials](#to-disable-individual-armor-materials) |||- - [Armor Registration](#armor-registration) |- - [disable_specific_materials](#to-disable-individual-armor-materials) |||- - [Armor Registration](#armor-registration)
|- - [armor_init_delay](#initialization-glitches-when-a-player-first-joins) |||- - [Registering Armor Groups](#registering-armor-groups) |- - [armor_init_delay](#initialization-glitches-when-a-player-first-joins) |||- - [Registering Armor Groups](#registering-armor-groups)
|- - [armor_init_times](#number-of-initialization-attempts) |||- - [Groups used by 3d_Armor](#groups-used-by-3d_armor) |- - [wieldview_update_time](#how-often-player-wield-items-are-updated) |||- - [Groups used by 3d_Armor](#groups-used-by-3d_armor)
|- - [armor_bones_delay](#armor-not-in-bones-due-to-server-lag) |||- - - [Elements](#elements) |- - [armor_bones_delay](#armor-not-in-bones-due-to-server-lag) |||- - - [Elements](#elements)
|- - [armor_update_time](#how-often-player-armor-items-are-updated) |||- - - [Attributes](#attributes) |- - [armor_update_time](#how-often-player-armor-items-are-updated) |||- - - [Attributes](#attributes)
|- - [armor_drop](#drop-armor-when-a-player-dies) |||- - - [Physics](#physics) |- - [armor_drop](#drop-armor-when-a-player-dies) |||- - - [Physics](#physics)
@ -19,7 +19,7 @@
|- - [armor_fire_protect](#enable-fire-protection) |||- - - [armor:remove_all](#armor-remove_all) |- - [armor_fire_protect](#enable-fire-protection) |||- - - [armor:remove_all](#armor-remove_all)
|- - [armor_punch_damage](#enable-punch-damage-effects) |||- - - [armor:equip](#armor-equip) |- - [armor_punch_damage](#enable-punch-damage-effects) |||- - - [armor:equip](#armor-equip)
|- - [armor_migrate_old_inventory](#migration-of-old-armor-inventories) |||- - - [armor:unequip](#armor-unequip) |- - [armor_migrate_old_inventory](#migration-of-old-armor-inventories) |||- - - [armor:unequip](#armor-unequip)
|- - [wieldview_update_time](#how-often-player-wield-items-are-updated) |||- - - [armor:update_skin](#armor-update_skin) | |||- - - [armor:update_skin](#armor-update_skin)
|-[Credits](#credits) |||- - [Callbacks](#Callbacks) |-[Credits](#credits) |||- - [Callbacks](#Callbacks)
| |||- - - [Item callbacks](#item-callbacks) | |||- - - [Item callbacks](#item-callbacks)
| |||- - - [Global callbacks](#global-callbacks) | |||- - - [Global callbacks](#global-callbacks)
@ -60,11 +60,6 @@ Change the following default settings by going to Main Menu>>Settings(Tab)>>All
armor_init_delay = 2 armor_init_delay = 2
### Number of initialization attempts
**Increase to prevent glitches - Use in conjunction with armor_init_delay if initialization problems persist.**
armor_init_times = 10
### Armor not in bones due to server lag ### Armor not in bones due to server lag
**Increase to help resolve** **Increase to help resolve**

View File

@ -162,7 +162,6 @@ armor = {
armor.config = { armor.config = {
init_delay = 2, init_delay = 2,
init_times = 10,
bones_delay = 1, bones_delay = 1,
update_time = 1, update_time = 1,
drop = minetest.get_modpath("bones") ~= nil, drop = minetest.get_modpath("bones") ~= nil,
@ -809,9 +808,6 @@ end
-- @tparam[opt] bool listring Use `listring` formspec element (default: `false`). -- @tparam[opt] bool listring Use `listring` formspec element (default: `false`).
-- @treturn string Formspec formatted string. -- @treturn string Formspec formatted string.
armor.get_armor_formspec = function(self, name, listring) armor.get_armor_formspec = function(self, name, listring)
if armor.def[name].init_time == 0 then
return "label[0,0;Armor not initialized!]"
end
local formspec = armor.formspec.. local formspec = armor.formspec..
"list[detached:"..name.."_armor;armor;0,0.5;2,3;]" "list[detached:"..name.."_armor;armor;0,0.5;2,3;]"
if listring == true then if listring == true then

View File

@ -35,10 +35,6 @@ ARMOR_FIRE_NODES = {
-- Increase this if you get initialization glitches when a player first joins. -- Increase this if you get initialization glitches when a player first joins.
ARMOR_INIT_DELAY = 1 ARMOR_INIT_DELAY = 1
-- Number of initialization attempts.
-- Use in conjunction with ARMOR_INIT_DELAY if initialization problems persist.
ARMOR_INIT_TIMES = 1
-- Increase this if armor is not getting into bones due to server lag. -- Increase this if armor is not getting into bones due to server lag.
ARMOR_BONES_DELAY = 1 ARMOR_BONES_DELAY = 1

View File

@ -2,7 +2,6 @@ local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath(modname) local modpath = minetest.get_modpath(modname)
local worldpath = minetest.get_worldpath() local worldpath = minetest.get_worldpath()
local last_punch_time = {} local last_punch_time = {}
local pending_players = {}
local timer = 0 local timer = 0
dofile(modpath.."/api.lua") dofile(modpath.."/api.lua")
@ -181,11 +180,7 @@ local function validate_armor_inventory(player)
end end
local function init_player_armor(initplayer) local function init_player_armor(initplayer)
local name = initplayer:get_player_name() local name = assert(initplayer:get_player_name())
local pos = initplayer:get_pos()
if not name or not pos then
return false
end
local armor_inv = minetest.create_detached_inventory(name.."_armor", { local armor_inv = minetest.create_detached_inventory(name.."_armor", {
on_put = function(inv, listname, index, stack, player) on_put = function(inv, listname, index, stack, player)
validate_armor_inventory(player) validate_armor_inventory(player)
@ -256,7 +251,6 @@ local function init_player_armor(initplayer)
end end
end end
armor.def[name] = { armor.def[name] = {
init_time = minetest.get_gametime(),
level = 0, level = 0,
state = 0, state = 0,
count = 0, count = 0,
@ -289,7 +283,6 @@ local function init_player_armor(initplayer)
end end
end end
armor:set_player_armor(initplayer) armor:set_player_armor(initplayer)
return true
end end
-- Armor Player Model -- Armor Player Model
@ -330,15 +323,7 @@ end)
minetest.register_on_joinplayer(function(player) minetest.register_on_joinplayer(function(player)
default.player_set_model(player, "3d_armor_character.b3d") default.player_set_model(player, "3d_armor_character.b3d")
local player_name = player:get_player_name() init_player_armor(player)
minetest.after(0, function()
-- TODO: Added in 7566ecc - What's the prupose?
local pplayer = minetest.get_player_by_name(player_name)
if pplayer and init_player_armor(pplayer) == false then
pending_players[pplayer] = 0
end
end)
end) end)
minetest.register_on_leaveplayer(function(player) minetest.register_on_leaveplayer(function(player)
@ -347,7 +332,6 @@ minetest.register_on_leaveplayer(function(player)
armor.def[name] = nil armor.def[name] = nil
armor.textures[name] = nil armor.textures[name] = nil
end end
pending_players[player] = nil
end) end)
if armor.config.drop == true or armor.config.destroy == true then if armor.config.drop == true or armor.config.destroy == true then
@ -469,18 +453,6 @@ minetest.register_globalstep(function(dtime)
end end
timer = 0 timer = 0
for player, count in pairs(pending_players) do
local remove = init_player_armor(player) == true
pending_players[player] = count + 1
if remove == false and count > armor.config.init_times then
minetest.log("warning", "3d_armor: Failed to initialize player")
remove = true
end
if remove == true then
pending_players[player] = nil
end
end
-- water breathing protection, added by TenPlus1 -- water breathing protection, added by TenPlus1
if armor.config.water_protect == true then if armor.config.water_protect == true then
for _,player in pairs(minetest.get_connected_players()) do for _,player in pairs(minetest.get_connected_players()) do

View File

@ -2,3 +2,4 @@ name = 3d_armor
depends = default, player_api depends = default, player_api
optional_depends = player_monoids, armor_monoid, pova, moreores optional_depends = player_monoids, armor_monoid, pova, moreores
description = Adds craftable armor that is visible to other players. description = Adds craftable armor that is visible to other players.
min_minetest_version = 5.0

View File

@ -33,9 +33,6 @@ unified_inventory.register_page("armor", {
local gridy = 0.6 local gridy = 0.6
local name = player:get_player_name() local name = player:get_player_name()
if armor.def[name].init_time == 0 then
return {formspec="label[0,0;"..F(S("Armor not initialized!")).."]"}
end
local formspec = perplayer_formspec.standard_inv_bg.. local formspec = perplayer_formspec.standard_inv_bg..
perplayer_formspec.standard_inv.. perplayer_formspec.standard_inv..
ui.make_inv_img_grid(gridx, gridy, 2, 3).. ui.make_inv_img_grid(gridx, gridy, 2, 3)..

View File

@ -13,10 +13,6 @@ armor_material_nether (Enable nether armor) bool true
# Increase this if you get initialization glitches when a player first joins. # Increase this if you get initialization glitches when a player first joins.
armor_init_delay (Initialization delay) int 2 armor_init_delay (Initialization delay) int 2
# Number of initialization attempts.
# Use in conjunction with armor_init_delay if initialization problems persist.
armor_init_times (Initialization attempts) int 10
# Increase this if armor is not getting into bones due to server lag. # Increase this if armor is not getting into bones due to server lag.
armor_bones_delay (Delay for bones) int 1 armor_bones_delay (Delay for bones) int 1