replacing ipairs with pairs

This commit is contained in:
Pao
2023-02-11 22:00:53 +01:00
parent 3ea76e8834
commit bd87cd7777
9 changed files with 22 additions and 28 deletions

View File

@@ -11,7 +11,7 @@ local function TocCheckIfStillInfected(limbs_data)
local check = false
for _, v in ipairs(GetBodyParts()) do
for _, v in pairs(GetBodyParts()) do
if limbs_data[v].is_infected then
check = true
end
@@ -37,8 +37,8 @@ local function TocCureInfection(body_damage, part_name)
-- TODO I think this is enough... we should just cycle if with everything instead of that crap up there
for i = body_part_types:size() - 1, 0, -1 do
local bodyPart = body_part_types:get(i);
bodyPart:SetInfected(false);
local bodyPart = body_part_types:get(i)
bodyPart:SetInfected(false)
end
if body_part_type:scratched() then body_part_type:setScratched(false, false) end

View File

@@ -20,13 +20,10 @@ local function FixSingleBodyPartType(body_part_type, use_oven)
end
local function SetBodyPartsStatusAfterOperation(player, limbs_data, part_name, use_oven)
--for _, v in ipairs(GetBodyParts()) do
local body_part_type = player:getBodyDamage():getBodyPart(TocGetAdiacentBodyPartFromPartName(part_name))
FixSingleBodyPartType(body_part_type, use_oven)
for _, v in ipairs(limbs_data[part_name].depends_on) do
for _, v in pairs(limbs_data[part_name].depends_on) do
local depended_body_part_type = player:getBodyDamage():getBodyPart(TocGetAdiacentBodyPartFromPartName(v))
FixSingleBodyPartType(depended_body_part_type, use_oven)

View File

@@ -16,7 +16,7 @@ TocContextMenus.CreateMenus = function(player, context, worldObjects, test)
local local_player = getSpecificPlayer(player)
--local players = getOnlinePlayers()
for k, v in ipairs(worldObjects) do
for k, v in pairs(worldObjects) do
-- help detecting a player by checking nearby squares
for x = v:getSquare():getX() - 1, v:getSquare():getX() + 1 do
for y = v:getSquare():getY() - 1, v:getSquare():getY() + 1 do
@@ -79,6 +79,7 @@ TocContextMenus.CreateOperateWithOvenMenu = function(player, context, worldObjec
-- Check temperature
if v_stove:getCurrentTemperature() > 250 then
-- ipairs here to keep the order
for _, v_bodypart in ipairs(GetBodyParts()) do
if part_data[v_bodypart].is_cut and part_data[v_bodypart].is_amputation_shown and
not part_data[v_bodypart].is_operated then

View File

@@ -4,6 +4,10 @@ if TheOnlyCure == nil then
TheOnlyCure = {}
end
local pairs = pairs
-----------------------------------------
-- MP HANDLING CHECKS
function CheckIfCanBeCut(part_name, limbs_data)
@@ -60,9 +64,8 @@ end
function CheckIfItemIsProsthesis(item)
-- TODO find a cleaner way
local item_full_type = item:getFullType()
local prosthesis_list = GetProsthesisList()
local prosthesis_list = GetProsthesisList() -- TODO this isn't gonna work after the modular prost rewrite
for _, v in pairs(prosthesis_list) do
if v == item_full_type then
@@ -88,7 +91,7 @@ end
function CheckIfProsthesisAlreadyInstalled(limbs_data, part_name)
for _, side in ipairs(TOC_sides) do
for _, side in pairs(TOC_sides) do
if string.find(part_name, side) then
return (limbs_data[side .. "_Hand"].is_prosthesis_equipped or limbs_data[side .. "_LowerArm"].is_prosthesis_equipped)
end

View File

@@ -74,7 +74,7 @@ end
-- Override and mod compat helper
function TocPopulateCanBeHeldTable(can_be_held, limbs_data)
for _, side in ipairs(TOC_sides) do
for _, side in pairs(TOC_sides) do
can_be_held[side] = true
if limbs_data[side .. "_Hand"].is_cut then

View File

@@ -66,8 +66,8 @@ local function TocUpdateBaseData(mod_data)
local accepted_prosthesis_upperarm = {} -- For future stuff
local accepted_prosthesis_foot = {}
for _, side in ipairs(TOC_sides) do
for _, limb in ipairs(TOC_limbs) do
for _, side in pairs(TOC_sides) do
for _, limb in pairs(TOC_limbs) do
local part_name = side .. "_" .. limb
@@ -205,8 +205,8 @@ local function TocSetInitData(mod_data, player)
for _, side in ipairs(TOC_sides) do
for _, limb in ipairs(TOC_limbs) do
for _, side in pairs(TOC_sides) do
for _, limb in pairs(TOC_limbs) do
local part_name = side .. "_" .. limb

View File

@@ -151,7 +151,7 @@ function ISEquipWeaponAction:perform()
if self.item then
local item_name = self.item:getFullType()
for _, prost_v in ipairs(GetProsthesisList()) do
for _, prost_v in pairs(GetProsthesisList()) do
local prosthesis_name = string.match(item_name, prost_v)
if prosthesis_name then
self.character:Say("This isn't the right way to equip this...")

View File

@@ -19,7 +19,7 @@ local function CheckIfPlayerIsInfected(player, toc_data)
end
-- Check for everything else
for _, v in ipairs(GetOtherBodyPartTypes()) do
for _, v in pairs(GetOtherBodyPartTypes()) do
if body_damage:getBodyPart(v):bitten() then
toc_data.Limbs.is_other_bodypart_infected = true -- Even one is enough, stop cycling if we find it
break
@@ -198,7 +198,7 @@ local function TocUpdateEveryTenMinutes()
local part_data = player:getModData().TOC.Limbs
--Experience for prosthesis user
for _, side in ipairs(TOC_sides) do
for _, side in pairs(TOC_sides) do
if part_data[side .. "_Hand"].is_prosthesis_equipped or part_data[side .. "_LowerArm"].is_prosthesis_equipped then
player:getXp():AddXP(Perks[side .. "_Hand"], 4)
end