-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Possibility of defining currencies (#3699)
- Loading branch information
1 parent
ffe69a5
commit 40206c5
Showing
14 changed files
with
152 additions
and
108 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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
local config = {} | ||
|
||
local changeGold = Action() | ||
|
||
function changeGold.onUse(player, item, fromPosition, target, toPosition, isHotkey) | ||
local coin = config[item:getId()] | ||
if coin.changeTo and item.type == 100 then | ||
item:remove() | ||
player:addItem(coin.changeTo, 1) | ||
elseif coin.changeBack then | ||
item:remove(1) | ||
player:addItem(coin.changeBack, 100) | ||
else | ||
return false | ||
end | ||
return true | ||
end | ||
|
||
local currencyItems = Game.getCurrencyItems() | ||
for index, currency in pairs(currencyItems) do | ||
local back, to = currencyItems[index-1], currencyItems[index+1] | ||
local currencyId = currency:getId() | ||
config[currencyId] = { changeBack = back and back:getId(), changeTo = to and to:getId() } | ||
changeGold:id(currencyId) | ||
end | ||
|
||
changeGold: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
Oops, something went wrong.