Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

init-cleanup #115

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions 3d_armor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
|-[Armor Configuration](#armor-configuration) |||- - [3d_Armor Item Storage](#3d_armor-item-storage)
|- - [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_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_update_time](#how-often-player-armor-items-are-updated) |||- - - [Attributes](#attributes)
|- - [armor_drop](#drop-armor-when-a-player-dies) |||- - - [Physics](#physics)
Expand All @@ -19,7 +19,7 @@
|- - [armor_fire_protect](#enable-fire-protection) |||- - - [armor:remove_all](#armor-remove_all)
|- - [armor_punch_damage](#enable-punch-damage-effects) |||- - - [armor:equip](#armor-equip)
|- - [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)
| |||- - - [Item callbacks](#item-callbacks)
| |||- - - [Global callbacks](#global-callbacks)
Expand Down Expand Up @@ -60,11 +60,6 @@ Change the following default settings by going to Main Menu>>Settings(Tab)>>All

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
**Increase to help resolve**

Expand Down
4 changes: 0 additions & 4 deletions 3d_armor/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ armor = {

armor.config = {
init_delay = 2,
init_times = 10,
bones_delay = 1,
update_time = 1,
drop = minetest.get_modpath("bones") ~= nil,
Expand Down Expand Up @@ -809,9 +808,6 @@ end
-- @tparam[opt] bool listring Use `listring` formspec element (default: `false`).
-- @treturn string Formspec formatted string.
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..
"list[detached:"..name.."_armor;armor;0,0.5;2,3;]"
if listring == true then
Expand Down
4 changes: 0 additions & 4 deletions 3d_armor/armor.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ ARMOR_FIRE_NODES = {
-- Increase this if you get initialization glitches when a player first joins.
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.
ARMOR_BONES_DELAY = 1

Expand Down
32 changes: 2 additions & 30 deletions 3d_armor/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath(modname)
local worldpath = minetest.get_worldpath()
local last_punch_time = {}
local pending_players = {}
local timer = 0

dofile(modpath.."/api.lua")
Expand Down Expand Up @@ -181,11 +180,7 @@ local function validate_armor_inventory(player)
end

local function init_player_armor(initplayer)
local name = initplayer:get_player_name()
local pos = initplayer:get_pos()
if not name or not pos then
return false
end
local name = assert(initplayer:get_player_name())
local armor_inv = minetest.create_detached_inventory(name.."_armor", {
on_put = function(inv, listname, index, stack, player)
validate_armor_inventory(player)
Expand Down Expand Up @@ -256,7 +251,6 @@ local function init_player_armor(initplayer)
end
end
armor.def[name] = {
init_time = minetest.get_gametime(),
level = 0,
state = 0,
count = 0,
Expand Down Expand Up @@ -289,7 +283,6 @@ local function init_player_armor(initplayer)
end
end
armor:set_player_armor(initplayer)
return true
end

-- Armor Player Model
Expand Down Expand Up @@ -330,15 +323,7 @@ end)

minetest.register_on_joinplayer(function(player)
default.player_set_model(player, "3d_armor_character.b3d")
local player_name = player:get_player_name()

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)
init_player_armor(player)
end)

minetest.register_on_leaveplayer(function(player)
Expand All @@ -347,7 +332,6 @@ minetest.register_on_leaveplayer(function(player)
armor.def[name] = nil
armor.textures[name] = nil
end
pending_players[player] = nil
end)

if armor.config.drop == true or armor.config.destroy == true then
Expand Down Expand Up @@ -469,18 +453,6 @@ minetest.register_globalstep(function(dtime)
end
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
if armor.config.water_protect == true then
for _,player in pairs(minetest.get_connected_players()) do
Expand Down
1 change: 1 addition & 0 deletions 3d_armor/mod.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ name = 3d_armor
depends = default, player_api
optional_depends = player_monoids, armor_monoid, pova, moreores
description = Adds craftable armor that is visible to other players.
min_minetest_version = 5.0
3 changes: 0 additions & 3 deletions 3d_armor_ui/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ unified_inventory.register_page("armor", {
local gridy = 0.6

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..
perplayer_formspec.standard_inv..
ui.make_inv_img_grid(gridx, gridy, 2, 3)..
Expand Down
4 changes: 0 additions & 4 deletions settingtypes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ armor_material_nether (Enable nether armor) bool true
# Increase this if you get initialization glitches when a player first joins.
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.
armor_bones_delay (Delay for bones) int 1

Expand Down