From 6b48370b386d08d8dd9ce3d9b06e1b925d521087 Mon Sep 17 00:00:00 2001 From: Marco Date: Wed, 13 Nov 2024 15:35:53 -0300 Subject: [PATCH 1/2] fix: disable ladder effect and add support for all ladders (#3114) This PR updates the teleport action for ladders by disabling the effect when using the ladder and modifying the logic to support all ladder IDs dynamically. 1. The effect of moving up or down is now disabled when using the ladder. 2. The script now automatically recognizes all ladder IDs, removing the need for hardcoded values. --- data-canary/scripts/actions/other/sewer.lua | 12 ------------ .../scripts/actions/other/teleport.lua | 19 ------------------- .../scripts/actions/items}/ladder_up.lua | 9 +++------ 3 files changed, 3 insertions(+), 37 deletions(-) delete mode 100644 data-canary/scripts/actions/other/sewer.lua delete mode 100644 data-otservbr-global/scripts/actions/other/teleport.lua rename {data-canary/scripts/actions/other => data/scripts/actions/items}/ladder_up.lua (71%) diff --git a/data-canary/scripts/actions/other/sewer.lua b/data-canary/scripts/actions/other/sewer.lua deleted file mode 100644 index 2868e887ae5..00000000000 --- a/data-canary/scripts/actions/other/sewer.lua +++ /dev/null @@ -1,12 +0,0 @@ -local sewer = Action() - -function sewer.onUse(player, item, fromPosition, target, toPosition, isHotkey) - if item:getId() == 435 then - fromPosition.z = fromPosition.z + 1 - end - player:teleportTo(fromPosition, false) - return true -end - -sewer:id(435) -sewer:register() diff --git a/data-otservbr-global/scripts/actions/other/teleport.lua b/data-otservbr-global/scripts/actions/other/teleport.lua deleted file mode 100644 index 7e763f00594..00000000000 --- a/data-otservbr-global/scripts/actions/other/teleport.lua +++ /dev/null @@ -1,19 +0,0 @@ -local ladderTable = Game.getLadderIds() - -local upFloorIds = ladderTable - -local teleport = Action() - -function teleport.onUse(player, item, fromPosition, target, toPosition, isHotkey) - if table.contains(upFloorIds, item.itemid) then - fromPosition:moveUpstairs() - else - fromPosition.z = fromPosition.z + 1 - end - player:teleportTo(fromPosition, false) - return true -end - -teleport:id(435) -teleport:id(unpack(ladderTable)) -teleport:register() diff --git a/data-canary/scripts/actions/other/ladder_up.lua b/data/scripts/actions/items/ladder_up.lua similarity index 71% rename from data-canary/scripts/actions/other/ladder_up.lua rename to data/scripts/actions/items/ladder_up.lua index 80d811fa741..5ec5f7c5b67 100644 --- a/data-canary/scripts/actions/other/ladder_up.lua +++ b/data/scripts/actions/items/ladder_up.lua @@ -1,9 +1,9 @@ -local setting = { 1948, 1968, 5542, 20474, 20475, 28656, 31262 } +local ladderTable = Game.getLadderIds() local ladder = Action() function ladder.onUse(player, item, fromPosition, target, toPosition, isHotkey) - if table.contains(setting, item.itemid) then + if table.contains(ladderTable, item.itemid) then fromPosition:moveUpstairs() else fromPosition.z = fromPosition.z + 1 @@ -18,8 +18,5 @@ function ladder.onUse(player, item, fromPosition, target, toPosition, isHotkey) return true end -for index, value in ipairs(setting) do - ladder:id(value) -end - +ladder:id(435, unpack(ladderTable)) ladder:register() From 4ee11d6420f4070a10cae298a1e3c1439a788b75 Mon Sep 17 00:00:00 2001 From: Marco Date: Thu, 14 Nov 2024 13:31:13 -0300 Subject: [PATCH 2/2] fix: resolve nil index issue in destroy script callback (#3117) Fixed an error in the item destruction script where calling `ActionsLib.destroyItem` resulted in a `nil` reference. The function call was adjusted to use `destroyItem` directly, ensuring the script works correctly and avoids global index errors. --- data-canary/scripts/actions/other/destroy.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data-canary/scripts/actions/other/destroy.lua b/data-canary/scripts/actions/other/destroy.lua index 587df2f5ea7..62af94ab101 100644 --- a/data-canary/scripts/actions/other/destroy.lua +++ b/data-canary/scripts/actions/other/destroy.lua @@ -250,7 +250,7 @@ local setting = { local destroy = Action() function destroy.onUse(player, item, fromPosition, target, toPosition, isHotkey) - return ActionsLib.destroyItem(player, target, toPosition) + return destroyItem(player, target, toPosition) end for index, value in ipairs(setting) do