daily pastebin goal
61%
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local config =
  2.     {
  3.         itemToUpgradePos = {x = 995, y = 997, z = 7},
  4.         withStack = {x = 997, y = 997, z = 7},
  5.         possibleUpgrades =
  6.             {
  7.                 [2650] = {to = 21706, with = {id = 2650, qty = 3}},
  8.                 [2514] = {to = 21707, with = {id = 20135, qty = 10}}
  9.             }
  10.     }
  11.  
  12. local function countItems(fromId)
  13.     return Tile(Position(config.withStack)):getItemCountById(config.possibleUpgrades[fromId].with.id) >= config.possibleUpgrades[fromId].with.qty
  14. end
  15.  
  16. local function removeItems(fromId)
  17.     Tile(Position(config.itemToUpgradePos)):getItemById(fromId):transform(config.possibleUpgrades[fromId].to)
  18.     for i = 1, config.possibleUpgrades[fromId].with.qty do
  19.         Tile(Position(config.withStack)):getItemById(config.possibleUpgrades[fromId].with.id):remove(1)
  20.     end
  21.     return Position(config.itemToUpgradePos):sendMagicEffect(CONST_ME_MAGIC_GREEN) and Position(config.withStack):sendMagicEffect(CONST_ME_MAGIC_RED)
  22. end
  23.  
  24. function onUse(player, item, fromPosition, target, toPosition, isHotkey)
  25.     if item:getId() ~= 1946 then
  26.         return true and item:transform(1946)
  27.     end
  28.     item:transform(1945)
  29.     local itemId = Tile(Position(config.itemToUpgradePos)):getItems()[1]:getId()
  30.     if config.possibleUpgrades[itemId] ~= nil then
  31.         if countItems(itemId) then
  32.             removeItems(itemId)
  33.         else
  34.             player:sendCancelMessage('You don\'t have the required items.')
  35.             player:getPosition():sendMagicEffect(CONST_ME_POFF)
  36.         end
  37.     else
  38.         player:sendCancelMessage('This item is not upgradeable.')
  39.         player:getPosition():sendMagicEffect(CONST_ME_POFF)
  40.     end
  41.     return true
  42. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top