-
-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Bug] fixes some things and miscellaneous adjusts (#484)
• Added missing magic gold converter id • Fixed "MESSAGE_INFO_DESCR" not exists to correct enum "MESSAGE_EVENT_ADVANCE" • Added a function to check if the pack running is the global one and added checks to only run some codes in the global pack • Fixed to Hireling Lamp so it cannot be moved • Indented "gamestore.lua" script for tab and removed several whitespace
- Loading branch information
Showing
9 changed files
with
4,613 additions
and
4,521 deletions.
There are no files selected for viewing
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
79 changes: 79 additions & 0 deletions
79
data-canary/scripts/actions/tools/magic_gold_converter.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,79 @@ | ||
local data = { | ||
converterIds = { | ||
[28525] = 28526, | ||
[28526] = 28525, | ||
}, | ||
coins = { | ||
[ITEM_GOLD_COIN] = ITEM_PLATINUM_COIN, | ||
[ITEM_PLATINUM_COIN] = ITEM_CRYSTAL_COIN | ||
} | ||
} | ||
|
||
local function findItem(self, cylinder, converterItem) | ||
if cylinder == 0 then | ||
cylinder = self:getSlotItem(CONST_SLOT_BACKPACK) | ||
findItem(self, self:getSlotItem(CONST_SLOT_STORE_INBOX), converterItem) | ||
end | ||
|
||
if cylinder and cylinder:isContainer() then | ||
for i = 0, cylinder:getSize() - 1 do | ||
local item = cylinder:getItem(i) | ||
if item:isContainer() then | ||
if findItem(self, Container(item.uid), converterItem) then | ||
-- Breaks the recursion from going into the next items in this cylinder | ||
return true | ||
end | ||
else | ||
for fromid, toid in pairs(data.coins) do | ||
if item:getId() == fromid and item:getCount() == 100 then | ||
item:remove() | ||
if not cylinder:addItem(toid, 1) then | ||
player:addItem(toid, 1) | ||
end | ||
|
||
converterItem:setAttribute(ITEM_ATTRIBUTE_CHARGES, converterItem:getAttribute(ITEM_ATTRIBUTE_CHARGES) - 1) | ||
return true | ||
end | ||
end | ||
end | ||
end | ||
-- End of items in this cylinder, returning to parent cylinder or finishing iteration | ||
return false | ||
end | ||
end | ||
|
||
local function startConversion(playerId, itemId) | ||
local player = Player(playerId) | ||
if player ~= nil then | ||
local converting = addEvent(startConversion, 300, playerId, itemId) | ||
local item = player:getItemById(itemId,true) | ||
if player:getItemCount(itemId) >= 1 then | ||
if item:hasAttribute(ITEM_ATTRIBUTE_CHARGES) then | ||
local charges_n = item:getAttribute(ITEM_ATTRIBUTE_CHARGES) | ||
if charges_n >= 1 then | ||
if player:getItemCount(ITEM_GOLD_COIN) >= 100 or player:getItemCount(ITEM_PLATINUM_COIN) >= 100 then | ||
findItem(player, 0, item) | ||
end | ||
else | ||
item:remove(1) | ||
stopEvent(converting) | ||
end | ||
end | ||
else | ||
stopEvent(converting) | ||
end | ||
end | ||
return true | ||
end | ||
|
||
local magicGoldConverter = Action() | ||
|
||
function magicGoldConverter.onUse(player, item, fromPosition, target, toPosition, isHotkey) | ||
item:transform(data.converterIds[item.itemId]) | ||
item:decay() | ||
startConversion(player:getId(), 28526) | ||
return true | ||
end | ||
|
||
magicGoldConverter:id(28525, 28526) | ||
magicGoldConverter:register() |
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
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
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
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
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
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
Oops, something went wrong.