forked from opentibiabr/canary
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: simplify code and use table for transformations (opentibiab…
…r#2196) Refactored the code to make it more modular and understandable, using a table to store transformation IDs in a more compact manner. --------- Co-authored-by: GitHub Actions <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
a61ba58
commit 9169b01
Showing
2 changed files
with
42 additions
and
62 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
data-otservbr-global/scripts/actions/object/golden_outfit_display.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
local transformations = { | ||
[31509] = 31500, | ||
[31500] = 31505, | ||
[31505] = 31513, | ||
[31513] = 31509, | ||
[31510] = 31502, | ||
[31502] = 31506, | ||
[31506] = 31514, | ||
[31514] = 31510, | ||
[31511] = 31503, | ||
[31503] = 31507, | ||
[31507] = 31515, | ||
[31515] = 31511, | ||
[31512] = 31504, | ||
[31504] = 31508, | ||
[31508] = 31516, | ||
[31516] = 31512, | ||
} | ||
|
||
local goldenOutfitDisplay = Action() | ||
|
||
function goldenOutfitDisplay.onUse(player, item, fromPosition, target, toPosition, isHotkey) | ||
local newItemID = transformations[item:getId()] | ||
if not newItemID then | ||
return true | ||
end | ||
|
||
if player:getStorageValue(Storage.OutfitQuest.GoldenOutfit) == 3 then | ||
item:transform(newItemID) | ||
item:getPosition():sendMagicEffect(CONST_ME_EARLY_THUNDER) | ||
else | ||
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need Full Golden Outfit to use it.") | ||
item:getPosition():sendMagicEffect(CONST_ME_POFF) | ||
end | ||
return true | ||
end | ||
|
||
for index, value in pairs(transformDisplay) do | ||
goldenOutfitDisplay:id(index) | ||
end | ||
|
||
goldenOutfitDisplay:register() |
62 changes: 0 additions & 62 deletions
62
data-otservbr-global/scripts/actions/other/golden_outfit_display.lua
This file was deleted.
Oops, something went wrong.