Alscara

alchemy.lua

Jun 24th, 2015
431
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.77 KB | None | 0 0
  1. function onUse(player, item, fromPosition, target, toPosition, isHotkey)
  2.     for i = 1, #aingredients do
  3.         if item.itemid == aingredients[i].id then
  4.             if player:getStorageValue(aingredients[i].storages[1]) ~= 1 then
  5.                 if aingredients[i].use == "with" and target == player then
  6.                     item:remove(1)
  7.                     player:setStorageValue(aingredients[i].storages[1], 1)
  8.                     player:say("Kind of chewy...", TALKTYPE_MONSTER_SAY)
  9.                     player:sendTextMessage(MESSAGE_INFO_DESCR, "You have discovered the effect " .. aeffects[aingredients[i].effects[1]].fullname .. " from the " .. aingredients[i].name .. "!")
  10.                     return true
  11.                 elseif aingredients[i].use == "use" then
  12.                     item:remove(1)
  13.                     player:setStorageValue(aingredients[i].storages[1], 1)
  14.                     player:say("Kind of chewy...", TALKTYPE_MONSTER_SAY)
  15.                     player:sendTextMessage(MESSAGE_INFO_DESCR, "You have discovered the effect " .. aeffects[aingredients[i].effects[1]].fullname .. " from the " .. aingredients[i].name .. "!")
  16.                     return true
  17.                 end
  18.             else
  19.                 if aingredients[i].use == "with" then
  20.                     if target == player then
  21.                         player:sendTextMessage(MESSAGE_INFO_DESCR, "You have already discovered the first effect for this item.")
  22.                     else
  23.                     return false
  24.                     end
  25.                 else
  26.                     player:sendTextMessage(MESSAGE_INFO_DESCR, "You have already discovered the first effect for this item.")
  27.                 end
  28.                 return true
  29.             end
  30.         end
  31.     end
  32.     return false
  33. end
Advertisement
Add Comment
Please, Sign In to add comment