diff --git a/mods/ENTITIES/mcl_boats/init.lua b/mods/ENTITIES/mcl_boats/init.lua index fb5e19ae45..01457c4bba 100644 --- a/mods/ENTITIES/mcl_boats/init.lua +++ b/mods/ENTITIES/mcl_boats/init.lua @@ -85,11 +85,12 @@ function boat.on_rightclick(self, clicker) {x = 0, y = 3.75, z = -1}, {x = 0, y = 0, z = 0}) clicker:set_properties({ visual_size = driver_visual_size }) mcl_player.player_attached[name] = true - minetest.after(0.2, function(clicker) - if clicker:is_player() then - mcl_player.player_set_animation(clicker, "sit" , 30) + minetest.after(0.2, function(name) + local player = minetest.get_player_by_name(name) + if player then + mcl_player.player_set_animation(player, "sit" , 30) end - end, clicker) + end, name) clicker:set_look_horizontal(self.object:getyaw()) end end diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index f3e02a0c3c..4c956af2fb 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -115,7 +115,8 @@ minetest.register_globalstep(function(dtime) if object:get_luaentity().init ~= true then object:get_luaentity().init = true minetest.after(1, function(args) - local player = args[1] + local playername = args[1] + local player = minetest.get_player_by_name(playername) local object = args[2] local lua = object:get_luaentity() if player == nil or not player:is_player() or object == nil or lua == nil or lua.itemstring == nil then @@ -136,7 +137,7 @@ minetest.register_globalstep(function(dtime) else enable_physics(object, object:get_luaentity()) end - end, {player, object}) + end, {player:get_player_name(), object}) end end end diff --git a/mods/ENTITIES/mobs_mc/1_items_default.lua b/mods/ENTITIES/mobs_mc/1_items_default.lua index f7f7c2c0b2..f705b78261 100644 --- a/mods/ENTITIES/mobs_mc/1_items_default.lua +++ b/mods/ENTITIES/mobs_mc/1_items_default.lua @@ -570,7 +570,8 @@ if c("totem") then scale = { x=17, y=17 }, offset = { x=0, y=-178 }, }) - minetest.after(3, function(player) + minetest.after(3, function(name) + local player = minetest.get_player_by_name(name) if player and player:is_player() then local name = player:get_player_name() if hud_totem[name] then @@ -578,7 +579,7 @@ if c("totem") then hud_totem[name] = nil end end - end, player) + end, player:get_player_name()) end -- Set HP to exactly 1 diff --git a/mods/HUD/awards/api.lua b/mods/HUD/awards/api.lua index 4fdab6fbf6..09f9291768 100644 --- a/mods/HUD/awards/api.lua +++ b/mods/HUD/awards/api.lua @@ -338,12 +338,16 @@ function awards.unlock(name, award) alignment = {x = 0, y = 0}, direction = 0, }) - minetest.after(3, function() + minetest.after(3, function(name) + local player = minetest.get_player_by_name(name) + if not player then + return + end player:hud_remove(one) player:hud_remove(two) player:hud_remove(three) player:hud_remove(four) - end) + end, player:get_player_name()) end end diff --git a/mods/ITEMS/mcl_jukebox/init.lua b/mods/ITEMS/mcl_jukebox/init.lua index 6ae5dbdfd2..2ee8f8c113 100644 --- a/mods/ITEMS/mcl_jukebox/init.lua +++ b/mods/ITEMS/mcl_jukebox/init.lua @@ -72,8 +72,8 @@ local function now_playing(player, track_id) active_huds[playername] = id end minetest.after(5, function(tab) - local player = tab[1] - local playername = player:get_player_name() + local playername = tab[1] + local player = minetest.get_player_by_name(playername) local id = tab[2] local seq = tab[3] if not player or not player:is_player() or not active_huds[playername] or not hud_sequence_numbers[playername] or seq ~= hud_sequence_numbers[playername] then @@ -83,7 +83,7 @@ local function now_playing(player, track_id) player:hud_remove(active_huds[playername]) active_huds[playername] = nil end - end, {player, id, hud_sequence_numbers[playername]}) + end, {playername, id, hud_sequence_numbers[playername]}) end diff --git a/mods/ITEMS/mcl_portals/portal_nether.lua b/mods/ITEMS/mcl_portals/portal_nether.lua index 637c0e8567..1c1f677421 100644 --- a/mods/ITEMS/mcl_portals/portal_nether.lua +++ b/mods/ITEMS/mcl_portals/portal_nether.lua @@ -404,6 +404,9 @@ minetest.register_abm({ end -- teleport the object minetest.after(3, function(obj, pos, target) + if not obj:get_luaentity() then + return + end -- Prevent quick back-and-forth teleportation if portal_cooloff[obj] then return diff --git a/mods/ITEMS/minetest-3d_armor/3d_armor/armor.lua b/mods/ITEMS/minetest-3d_armor/3d_armor/armor.lua index b765820535..4dfa92e836 100644 --- a/mods/ITEMS/minetest-3d_armor/3d_armor/armor.lua +++ b/mods/ITEMS/minetest-3d_armor/3d_armor/armor.lua @@ -292,11 +292,15 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end for field, _ in pairs(fields) do if string.find(field, "skins_set") then - minetest.after(0, function(player) + minetest.after(0, function(name) + local player = minetest.get_player_by_name(name) + if not player then + return + end local skin = armor:get_player_skin(name) armor.textures[name].skin = skin..".png" armor:set_player_armor(player) - end, player) + end, player:get_player_name()) end end end) @@ -406,9 +410,13 @@ minetest.register_on_joinplayer(function(player) end end for i=1, ARMOR_INIT_TIMES do - minetest.after(ARMOR_INIT_DELAY * i, function(player) + minetest.after(ARMOR_INIT_DELAY * i, function(name) + local player = minetest.get_player_by_name(name) + if not player then + return + end armor:set_player_armor(player) - end, player) + end, player:get_player_name()) end end) @@ -435,7 +443,7 @@ if ARMOR_DROP == true or ARMOR_DESTROY == true then end armor:set_player_armor(player) if ARMOR_DESTROY == false then - minetest.after(ARMOR_BONES_DELAY, function() + minetest.after(ARMOR_BONES_DELAY, function(pos, drop) local node = minetest.get_node(vector.round(pos)) if node then if node.name ~= "bones:bones" then @@ -461,7 +469,7 @@ if ARMOR_DROP == true or ARMOR_DESTROY == true then armor.drop_armor(pos, stack) end end - end) + end, pos, drop) end end) end diff --git a/mods/PLAYER/mcl_hunger/hunger.lua b/mods/PLAYER/mcl_hunger/hunger.lua index 72464320ea..d77a7b1874 100644 --- a/mods/PLAYER/mcl_hunger/hunger.lua +++ b/mods/PLAYER/mcl_hunger/hunger.lua @@ -85,9 +85,10 @@ local function reset_bars_poison_hunger(player) end -- Poison player -local function poisonp(tick, time, time_left, damage, exhaustion, player) +local function poisonp(tick, time, time_left, damage, exhaustion, name) + local player = minetest.get_player_by_name(name) -- First check if player is still there - if not player:is_player() then + if not player then return end local name = player:get_player_name() @@ -97,7 +98,7 @@ local function poisonp(tick, time, time_left, damage, exhaustion, player) end time_left = time_left + tick if time_left < time then - minetest.after(tick, poisonp, tick, time, time_left, damage, exhaustion, player) + minetest.after(tick, poisonp, tick, time, time_left, damage, exhaustion, name) else if damage > 0 then mcl_hunger.poison_damage[name] = mcl_hunger.poison_damage[name] - 1 @@ -236,7 +237,7 @@ function mcl_hunger.item_eat(hunger_change, replace_with_item, poisontime, poiso end mcl_hunger.poison_hunger[name] = mcl_hunger.poison_hunger[name] + 1 end - poisonp(1, poisontime, 0, poison, exhaust, user) + poisonp(1, poisontime, 0, poison, exhaust, user:get_player_name()) end end