Advertisement
regoldberg

Talisman Function Fixes

Mar 2nd, 2021
920
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.30 KB | None | 0 0
  1. -- Function to combine pieces required to get a specific level piece.
  2. talisman.make = function (piecename, level)
  3.     -- note this can fail currently because we cant control the talisman combine type so it cant combine promo with refined, etc.
  4.   local makinglevel = 1
  5.   local numberToCombine = 2^(level-1)
  6.   while makinglevel < level do
  7.     for i = 1, numberToCombine/2 do
  8.       send(string.format("talisman combine %s %s", piecename, makinglevel),false)
  9.     end
  10.     makinglevel = makinglevel+1
  11.     numberToCombine = numberToCombine/2
  12.   end
  13.     return true
  14. end
  15.  
  16.  
  17.  
  18. -- Logic to complete talismans.
  19. talisman.complete = function (talismanname)
  20.     if not talisman.cancomplete(talismanname) then
  21.         talisman.echo(string.format("Cannot complete talisman %s, pieces missing.", talismanname))
  22.         return
  23.     end
  24.  
  25.     for k,d in pairs(talisman.info[talismanname]) do
  26.         local required = (math.log(d.required)/math.log(2))+1
  27.         if math.floor(required)==required then
  28.       talisman.make(k, required)
  29.       talisman.remove(k,1,d.required)
  30.       --still have to remove as singles because we keep all pieces as singles
  31.         else
  32.             -- if required is 3, we cant combine this, so use 3 singles (mudbomb for example)..
  33.             talisman.remove(k, 1, d.required)
  34.         end
  35.     end
  36.     send(string.format("Talisman complete %s", talismanname))
  37. end
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement