diff --git a/scripts/commands/addlights.lua b/scripts/commands/addlights.lua index d66990a5613..5f160f65d44 100644 --- a/scripts/commands/addlights.lua +++ b/scripts/commands/addlights.lua @@ -43,7 +43,7 @@ commandObj.onTrigger = function(player, light, amount, target) local selectedLight = tostring(light) - if lightType[selectedLight] == nil or selectedLight == nil then + if lightType[selectedLight] == nil or selectedLight == nil then error(player, 'Invalid light type.\nValid light types: pearl, azure, ruby, amber, gold, silver, ebon') return end diff --git a/scripts/globals/garrison.lua b/scripts/globals/garrison.lua index 5732bc97527..78ea28d0541 100644 --- a/scripts/globals/garrison.lua +++ b/scripts/globals/garrison.lua @@ -113,7 +113,7 @@ xi.garrison.getAllyInfo = function(zoneID, zoneData, nationID) allyName == nil or allyGroupId == nil or allyLooks == nil or - #allyLooks == 0 or + #allyLooks == 0 or pos == nil then local zone = GetZone(zoneID) diff --git a/scripts/missions/wotg/04_The_Queen_of_the_Dance.lua b/scripts/missions/wotg/04_The_Queen_of_the_Dance.lua index a3db48030fd..094e130f190 100644 --- a/scripts/missions/wotg/04_The_Queen_of_the_Dance.lua +++ b/scripts/missions/wotg/04_The_Queen_of_the_Dance.lua @@ -21,8 +21,8 @@ mission.sections = -- 0: Try to enter without a ticket { check = function(player, currentMission, missionStatus, vars) - return currentMission == mission.missionId and missionStatus == 0 - and xi.wotg.helpers.meetsMission4Reqs(player) + return currentMission == mission.missionId and missionStatus == 0 and + xi.wotg.helpers.meetsMission4Reqs(player) end, [xi.zone.SOUTHERN_SAN_DORIA_S] = diff --git a/scripts/quests/ahtUrhgan/Promotion_Superior_Private.lua b/scripts/quests/ahtUrhgan/Promotion_Superior_Private.lua index da25256a363..decf0215331 100644 --- a/scripts/quests/ahtUrhgan/Promotion_Superior_Private.lua +++ b/scripts/quests/ahtUrhgan/Promotion_Superior_Private.lua @@ -15,8 +15,8 @@ quest.sections = { { check = function(player, status, vars) - return status == QUEST_AVAILABLE and player:getCharVar('AssaultPromotion') >= 25 - and player:getQuestStatus(xi.quest.log_id.AHT_URHGAN, xi.quest.id.ahtUrhgan.PROMOTION_PRIVATE_FIRST_CLASS) == QUEST_COMPLETED + return status == QUEST_AVAILABLE and player:getCharVar('AssaultPromotion') >= 25 and + player:getQuestStatus(xi.quest.log_id.AHT_URHGAN, xi.quest.id.ahtUrhgan.PROMOTION_PRIVATE_FIRST_CLASS) == QUEST_COMPLETED end, [xi.zone.AHT_URHGAN_WHITEGATE] = diff --git a/scripts/quests/crystalWar/Downward_Helix.lua b/scripts/quests/crystalWar/Downward_Helix.lua index 95f9156040f..d2432742101 100644 --- a/scripts/quests/crystalWar/Downward_Helix.lua +++ b/scripts/quests/crystalWar/Downward_Helix.lua @@ -2,8 +2,8 @@ -- Downward Helix ----------------------------------- -- !addquest 7 33 --- Erlene : !pos 376.936 -39.999 17.914 175 --- Indescript Markings : !pos 322 24 113 98 +-- Erlene : !pos 376.936 -39.999 17.914 175 +-- Indescript Markings : !pos 322 24 113 98 ----------------------------------- local quest = Quest:new(xi.quest.log_id.CRYSTAL_WAR, xi.quest.id.crystalWar.DOWNWARD_HELIX) @@ -18,7 +18,7 @@ quest.sections = { check = function(player, status, vars) return status == QUEST_AVAILABLE and - xi.quest.getVar(player, xi.quest.log_id.CRYSTAL_WAR, xi.quest.id.crystalWar.ON_SABBATICAL, 'Timer') <= VanadielUniqueDay() and + xi.quest.getVar(player, xi.quest.log_id.CRYSTAL_WAR, xi.quest.id.crystalWar.ON_SABBATICAL, 'Timer') <= VanadielUniqueDay() and player:getMainJob() == xi.job.SCH and player:getMainLvl() >= xi.settings.main.AF2_QUEST_LEVEL end, diff --git a/scripts/zones/Grand_Palace_of_HuXzoi/mobs/DE_Quasilumin.lua b/scripts/zones/Grand_Palace_of_HuXzoi/mobs/DE_Quasilumin.lua index fef3cef1139..0e952c5524a 100644 --- a/scripts/zones/Grand_Palace_of_HuXzoi/mobs/DE_Quasilumin.lua +++ b/scripts/zones/Grand_Palace_of_HuXzoi/mobs/DE_Quasilumin.lua @@ -237,7 +237,7 @@ entity.onMobRoam = function(mob) for _, doorID in ipairs(escort.doors) do local npc = GetNPCByID(doorID) - if doorID ~= openedDoor and mob:checkDistance(npc) <= 8 then + if doorID ~= openedDoor and mob:checkDistance(npc) <= 8 then npc:setAnimation(xi.animation.OPEN_DOOR) mob:setLocalVar('opened_door', doorID) end diff --git a/scripts/zones/Rolanberry_Fields/npcs/Saarlan.lua b/scripts/zones/Rolanberry_Fields/npcs/Saarlan.lua index b3ac1a55193..dd85b998164 100644 --- a/scripts/zones/Rolanberry_Fields/npcs/Saarlan.lua +++ b/scripts/zones/Rolanberry_Fields/npcs/Saarlan.lua @@ -59,12 +59,14 @@ entity.onTrigger = function(player, npc) elseif player:getCharVar('LegionStatus') == 1 then local maximus = player:hasKeyItem(xi.ki.LEGION_TOME_PAGE_MAXIMUS) and 1 or 0 local minimus = player:hasKeyItem(xi.ki.LEGION_TOME_PAGE_MINIMUS) and 1 or 0 + + -- TODO: Table these and iterate local title = - (player:hasTitle(xi.title.SUBJUGATOR_OF_THE_LOFTY) and 1 or 0) + - (player:hasTitle(xi.title.SUBJUGATOR_OF_THE_MIRED) and 2 or 0) + - (player:hasTitle(xi.title.SUBJUGATOR_OF_THE_SOARING) and 4 or 0) + - (player:hasTitle(xi.title.SUBJUGATOR_OF_THE_VEILED) and 8 or 0) + - (player:hasTitle(xi.title.LEGENDARY_LEGIONNAIRE) and 16 or 0) + (player:hasTitle(xi.title.SUBJUGATOR_OF_THE_LOFTY) and 1 or 0) + + (player:hasTitle(xi.title.SUBJUGATOR_OF_THE_MIRED) and 2 or 0) + + (player:hasTitle(xi.title.SUBJUGATOR_OF_THE_SOARING) and 4 or 0) + + (player:hasTitle(xi.title.SUBJUGATOR_OF_THE_VEILED) and 8 or 0) + + (player:hasTitle(xi.title.LEGENDARY_LEGIONNAIRE) and 16 or 0) player:startEvent(8005, 0, title, maximus, player:getCurrency('legion_point'), minimus) end diff --git a/scripts/zones/Sea_Serpent_Grotto/npcs/_4w3.lua b/scripts/zones/Sea_Serpent_Grotto/npcs/_4w3.lua index bb2a21e2560..c1370ad583a 100644 --- a/scripts/zones/Sea_Serpent_Grotto/npcs/_4w3.lua +++ b/scripts/zones/Sea_Serpent_Grotto/npcs/_4w3.lua @@ -20,7 +20,7 @@ entity.onTrigger = function(player, npc) local zPos = player:getZPos() local mythrilDoorCheck = player:getCharVar('SSG_MythrilDoor') - if xPos >= 40 and zPos >= 15 then + if xPos >= 40 and zPos >= 15 then if mythrilDoorCheck == 0 then -- Door has never been checked player:messageSpecial(ID.text.FIRST_CHECK) player:setCharVar('SSG_MythrilDoor', 1) diff --git a/scripts/zones/Yuhtunga_Jungle/npcs/qm2.lua b/scripts/zones/Yuhtunga_Jungle/npcs/qm2.lua index 29fe0e0b8e1..e07e546aa11 100644 --- a/scripts/zones/Yuhtunga_Jungle/npcs/qm2.lua +++ b/scripts/zones/Yuhtunga_Jungle/npcs/qm2.lua @@ -8,11 +8,11 @@ local ID = zones[xi.zone.YUHTUNGA_JUNGLE] local entity = {} local function isFightInProgress() - return GetMobByID(ID.mob.NASUS_OFFSET):isAlive() - or GetMobByID(ID.mob.NASUS_OFFSET + 1):isAlive() - or GetMobByID(ID.mob.NASUS_OFFSET + 2):isAlive() - or GetMobByID(ID.mob.NASUS_OFFSET + 3):isAlive() - or GetMobByID(ID.mob.NASUS_OFFSET + 4):isAlive() + return GetMobByID(ID.mob.NASUS_OFFSET):isAlive() or + GetMobByID(ID.mob.NASUS_OFFSET + 1):isAlive() or + GetMobByID(ID.mob.NASUS_OFFSET + 2):isAlive() or + GetMobByID(ID.mob.NASUS_OFFSET + 3):isAlive() or + GetMobByID(ID.mob.NASUS_OFFSET + 4):isAlive() end local function spawnNMs(player) diff --git a/tools/ci/lua_stylecheck.py b/tools/ci/lua_stylecheck.py index 87233a2a58f..3aa31155b0b 100644 --- a/tools/ci/lua_stylecheck.py +++ b/tools/ci/lua_stylecheck.py @@ -145,6 +145,16 @@ def check_parameter_padding(self, line): for _ in re.finditer(",[^ \n]", line): self.error("Multiple parameters used without an appropriate following space or newline") + def check_conditional_padding(self, line): + # \s{2,}(and|or)(\s{1,}|$)|\s{1,}(and|or)\s{2,} + + # lstrip current line to prevent false-positives. + # TODO: Handle lines starting with and|or, or ending with not in separate check + + code_line = line.lstrip() + if re.search("\s{2,}(and|or)(\s{1,}|$)|\s{1,}(and|or)\s{2,}", code_line): + self.error("Multiple spaces detected around logical operator.") + def check_semicolon(self, line): """No semi-colons should be used in Lua scripts. @@ -357,7 +367,7 @@ def run_style_check(self): self.error("Standard comment block lines of '-' should be 35 characters.") # Remove in-line comments - code_line = re.sub("(?=--)(.*?)(?=\r\n|\n)", "", line) + code_line = re.sub("(?=--)(.*?)(?=\r\n|\n)", "", line).rstrip() # Before replacing strings, see if we're only using single quotes and check requires if re.search(r"\"[^\"']*\"(?=(?:[^']*'[^']*')*[^']*$)", code_line): @@ -377,6 +387,7 @@ def run_style_check(self): self.check_variable_names(code_line) self.check_semicolon(code_line) self.check_indentation(code_line) + self.check_conditional_padding(code_line) self.check_operator_padding(code_line) self.check_parentheses_padding(code_line) self.check_no_single_line_functions(code_line) @@ -479,8 +490,8 @@ def run_style_check(self): for filename in glob.iglob('scripts/**/*.lua', recursive = True): total_errors += LuaStyleCheck(filename).errcount elif target == 'test': - total_errors = LuaStyleCheck('tools/ci/tests/stylecheck.lua', show_errors = False).errcount - expected_errors = 72 + total_errors = LuaStyleCheck('tools/ci/tests/stylecheck.lua', show_errors = True).errcount + expected_errors = 77 else: total_errors = LuaStyleCheck(target).errcount diff --git a/tools/ci/tests/stylecheck.lua b/tools/ci/tests/stylecheck.lua index 9370fa77689..5853f302189 100644 --- a/tools/ci/tests/stylecheck.lua +++ b/tools/ci/tests/stylecheck.lua @@ -220,3 +220,10 @@ require('scripts/zones/Bastok_Markets/IDs') -- FAIL -- Bad: ------------------------------------- --------------------------------- + +this and this -- PASS +this or this -- PASS +this and -- FAIL +this and this -- FAIL +this or -- FAIL +this or this -- FAIL