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