Guest User

Untitled

a guest
Mar 15th, 2023
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.25 KB | None | 0 0
  1. function onCollisionEnter(co)
  2.   ---------------
  3.   textline = '5/5'
  4.   ---------------
  5.  
  6.     local cardObject = co.collision_object
  7.   if not(cardObject.type == "Card") then return end
  8.  
  9.   enc = Global.getVar('Encoder')
  10.   if not(enc) then return end
  11.  
  12.   local pID = "_MTG_Simplified_UNIFIED"
  13.   local tyrantOn=enc.call("APIobjIsPropEnabled",{obj=cardObject,propID=pID})
  14.  
  15.   if not(tyrantOn) then return end
  16.  
  17.   local encData = enc.call("APIobjGetPropData",{obj=cardObject,propID=pID})
  18.   local data = encData["tyrantUnified"]
  19.   local basePow=tonumber(data.cardFaces[data.activeFace].basePower)
  20.   local baseTou=tonumber(data.cardFaces[data.activeFace].baseToughness)
  21.  
  22.   local newPow,newTou = textline:match('(%d+)/(%d+)')
  23.  
  24.   if basePow and baseTou and newPow and newTou then
  25.     data.displayPowTou = true
  26.     data.power = newPow - basePow
  27.     data.toughness = newTou - baseTou
  28.     enc.call("APIobjSetPropData",{obj=cardObject,propID=pID,data=encData})
  29.     enc.call("APIrebuildButtons",{obj=cardObject})
  30.   elseif newPow and newTou then
  31.     data.displayPowTou = true
  32.     data.power = newPow
  33.     data.toughness = newTou
  34.     enc.call("APIobjSetPropData",{obj=cardObject,propID=pID,data=encData})
  35.     enc.call("APIrebuildButtons",{obj=cardObject})
  36.   end
  37.  
  38. end
Advertisement
Add Comment
Please, Sign In to add comment