fix SO MANY pairs/ipairs
This commit is contained in:
parent
f35f80d79a
commit
5d17a6b699
|
@ -22,7 +22,7 @@ minetest.register_entity("mcl_burning:fire", {
|
|||
})
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
for _, player in ipairs(minetest.get_connected_players()) do
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
mcl_burning.tick(player, dtime)
|
||||
end
|
||||
end)
|
||||
|
|
|
@ -54,14 +54,14 @@ local disable_physics = function(object, luaentity, ignore_check, reset_movement
|
|||
end
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
for _,player in pairs(minetest.get_connected_players()) do
|
||||
if player:get_hp() > 0 or not minetest.settings:get_bool("enable_damage") then
|
||||
local pos = player:get_pos()
|
||||
local inv = player:get_inventory()
|
||||
local checkpos = {x=pos.x,y=pos.y + item_drop_settings.player_collect_height,z=pos.z}
|
||||
|
||||
--magnet and collection
|
||||
for _,object in ipairs(minetest.get_objects_inside_radius(checkpos, item_drop_settings.xp_radius_magnet)) do
|
||||
for _,object in pairs(minetest.get_objects_inside_radius(checkpos, item_drop_settings.xp_radius_magnet)) do
|
||||
if not object:is_player() and vector.distance(checkpos, object:get_pos()) < item_drop_settings.radius_magnet and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" and object:get_luaentity()._magnet_timer and (object:get_luaentity()._insta_collect or (object:get_luaentity().age > item_drop_settings.age)) then
|
||||
object:get_luaentity()._magnet_timer = object:get_luaentity()._magnet_timer + dtime
|
||||
local collected = false
|
||||
|
|
|
@ -226,7 +226,7 @@ local collision = function(self)
|
|||
local z = 0
|
||||
local width = -self.collisionbox[1] + self.collisionbox[4] + 0.5
|
||||
|
||||
for _,object in ipairs(minetest.get_objects_inside_radius(pos, width)) do
|
||||
for _,object in pairs(minetest.get_objects_inside_radius(pos, width)) do
|
||||
|
||||
if object:is_player()
|
||||
or (object:get_luaentity()._cmi_is_mob == true and object ~= self.object) then
|
||||
|
@ -4576,9 +4576,9 @@ local timer = 0
|
|||
minetest.register_globalstep(function(dtime)
|
||||
timer = timer + dtime
|
||||
if timer < 1 then return end
|
||||
for _, player in ipairs(minetest.get_connected_players()) do
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
local pos = player:get_pos()
|
||||
for _, obj in ipairs(minetest.get_objects_inside_radius(pos, 47)) do
|
||||
for _, obj in pairs(minetest.get_objects_inside_radius(pos, 47)) do
|
||||
local lua = obj:get_luaentity()
|
||||
if lua and lua._cmi_is_mob then
|
||||
lua.lifetimer = math.max(20, lua.lifetimer)
|
||||
|
|
|
@ -122,7 +122,7 @@ local arrows = {
|
|||
}
|
||||
|
||||
local throwing_shoot_arrow = function(itemstack, player)
|
||||
for _,arrow in ipairs(arrows) do
|
||||
for _,arrow in pairs(arrows) do
|
||||
if player:get_inventory():get_stack("main", player:get_wield_index()+1):get_name() == arrow[1] then
|
||||
if not minetest.is_creative_enabled(player:get_player_name()) then
|
||||
player:get_inventory():remove_item("main", arrow[1])
|
||||
|
|
|
@ -27,7 +27,7 @@ minetest.register_globalstep(function(dtime)
|
|||
if timer < 0.7 then return end
|
||||
timer = 0
|
||||
|
||||
for _, player in ipairs(minetest.get_connected_players()) do
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
if not mcl_worlds.has_dust(player:get_pos()) then
|
||||
return false
|
||||
end
|
||||
|
|
|
@ -118,7 +118,7 @@ minetest.register_globalstep(function(dtime)
|
|||
if main_timer > mcl_hbarmor.tick or timer > 4 then
|
||||
if minetest.settings:get_bool("enable_damage") then
|
||||
if main_timer > mcl_hbarmor.tick then main_timer = 0 end
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
for _,player in pairs(minetest.get_connected_players()) do
|
||||
local name = player:get_player_name()
|
||||
if mcl_hbarmor.player_active[name] == true then
|
||||
local ret = mcl_hbarmor.get_armor(player)
|
||||
|
|
|
@ -36,7 +36,7 @@ local function check_in_beds(players)
|
|||
players = minetest.get_connected_players()
|
||||
end
|
||||
|
||||
for n, player in ipairs(players) do
|
||||
for n, player in pairs(players) do
|
||||
local name = player:get_player_name()
|
||||
if not in_bed[name] then
|
||||
return false
|
||||
|
@ -102,8 +102,7 @@ local function lay_down(player, pos, bed_pos, state, skip)
|
|||
-- No sleeping if monsters nearby.
|
||||
-- The exceptions above apply.
|
||||
-- Zombie pigmen only prevent sleep while they are hostle.
|
||||
local objs = minetest.get_objects_inside_radius(bed_pos, 8)
|
||||
for _, obj in ipairs(objs) do
|
||||
for _, obj in pairs(minetest.get_objects_inside_radius(bed_pos, 8)) do
|
||||
if obj ~= nil and not obj:is_player() then
|
||||
local ent = obj:get_luaentity()
|
||||
local mobname = ent.name
|
||||
|
|
|
@ -341,7 +341,7 @@ controls.register_on_hold(function(player, key, time)
|
|||
end)
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
for _, player in ipairs(minetest.get_connected_players()) do
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
local name = player:get_player_name()
|
||||
local wielditem = player:get_wielded_item()
|
||||
local wieldindex = player:get_wield_index()
|
||||
|
|
|
@ -131,7 +131,7 @@ minetest.register_abm({
|
|||
interval = 0.5,
|
||||
chance = 1,
|
||||
action = function(pos, node)
|
||||
for _, obj in ipairs(minetest.get_objects_inside_radius(pos, 0.4)) do
|
||||
for _, obj in pairs(minetest.get_objects_inside_radius(pos, 0.4)) do
|
||||
if mcl_burning.is_burning(obj) then
|
||||
mcl_burning.extinguish(obj)
|
||||
local new_group = minetest.get_item_group(node.name, "cauldron_filled") - 1
|
||||
|
|
|
@ -94,9 +94,8 @@ minetest.register_globalstep(function(dtime)
|
|||
|
||||
watch.old_time = now
|
||||
|
||||
local players = minetest.get_connected_players()
|
||||
for p, player in ipairs(players) do
|
||||
for s, stack in ipairs(player:get_inventory():get_list("main")) do
|
||||
for p, player in pairs(minetest.get_connected_players()) do
|
||||
for s, stack in pairs(player:get_inventory():get_list("main")) do
|
||||
local dim = mcl_worlds.pos_to_dimension(player:get_pos())
|
||||
local frame
|
||||
-- Clocks do not work in certain zones
|
||||
|
|
|
@ -14,15 +14,14 @@ local random_frame = math.random(0, compass_frames-1)
|
|||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
random_timer = random_timer + dtime
|
||||
local players = minetest.get_connected_players()
|
||||
|
||||
if random_timer >= random_timer_trigger then
|
||||
random_frame = (random_frame + math.random(-1, 1)) % compass_frames
|
||||
random_timer = 0
|
||||
end
|
||||
for i,player in ipairs(players) do
|
||||
for i,player in pairs(minetest.get_connected_players()) do
|
||||
local function has_compass(player)
|
||||
for _,stack in ipairs(player:get_inventory():get_list("main")) do
|
||||
for _,stack in pairs(player:get_inventory():get_list("main")) do
|
||||
if minetest.get_item_group(stack:get_name(), "compass") ~= 0 then
|
||||
return true
|
||||
end
|
||||
|
|
|
@ -4,7 +4,7 @@ local S = minetest.get_translator("mcl_doors")
|
|||
local function on_place_node(place_to, newnode,
|
||||
placer, oldnode, itemstack, pointed_thing)
|
||||
-- Run script hook
|
||||
for _, callback in ipairs(minetest.registered_on_placenodes) do
|
||||
for _, callback in pairs(minetest.registered_on_placenodes) do
|
||||
-- Deep-copy pos, node and pointed_thing because callback can modify them
|
||||
local place_to_copy = {x = place_to.x, y = place_to.y, z = place_to.z}
|
||||
local newnode_copy =
|
||||
|
|
Loading…
Reference in New Issue