Advertisement
arcagamer

Magia relampago

Mar 23rd, 2023
461
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.06 KB | None | 0 0
  1. Here's a code snippet that should do what you're asking for:
  2.  
  3. ```lua
  4. local s,id,o=GetID()
  5. function s.initial_effect(c)
  6.     local e1=Effect.CreateEffect(c)
  7.     e1:SetType(EFFECT_TYPE_ACTIVATE)
  8.     e1:SetCode(EVENT_FREE_CHAIN)
  9.     e1:SetCondition(s.condition)
  10.     e1:SetTarget(s.target)
  11.     e1:SetOperation(s.activate)
  12.     c:RegisterEffect(e1)
  13. end
  14. function s.condition(e,tp,eg,ep,ev,re,r,rp)
  15.     return not Duel.IsExistingMatchingCard(aux.FilterFaceupFunction(Card.IsSetCard,0x123),tp,0,LOCATION_MZONE,1,nil) -- 0x123 is the setcode for "titan" monsters
  16. end
  17. function s.target(e,tp,eg,ep,ev,re,r,rp,chk)
  18.     if chk==0 then return Duel.IsExistingMatchingCard(s.filter,tp,LOCATION_DECK,0,1,nil) end
  19. end
  20. function s.filter(c)
  21.     return c:IsSetCard(0x456) and c:IsAbleToHand() -- 0x456 is the setcode for "lightning" cards
  22. end
  23. function s.activate(e,tp,eg,ep,ev,re,r,rp)
  24.     Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND)
  25.     local g=Duel.SelectMatchingCard(tp,s.filter,tp,LOCATION_DECK,0,1,1,nil)
  26.     if #g>0 then
  27.         Duel.SendtoHand(g,nil,REASON_EFFECT)
  28.         Duel.ConfirmCards(1-tp,g)
  29.         if g:GetFirst():IsCode(10000000) then -- 10000000 is the card code for "lightning-Maria"
  30.             Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
  31.             local g=Duel.SelectMatchingCard(tp,Card.IsFacedown,tp,0,LOCATION_ONFIELD,1,1,nil)
  32.             if #g>0 then
  33.                 Duel.Remove(g,POS_FACEDOWN,REASON_EFFECT)
  34.             end
  35.         end
  36.     end
  37. end
  38. ```
  39.  
  40. This script creates an effect for a spell card that can only be activated if your opponent controls no "titan" monsters. When activated it allows you to add 1 "lightning" card from your deck to your hand. If you added "lightning-Maria" with this effect it also allows you to banish one facedown card your opponent controls. The effect of this card can only be activated once per turn.
  41.  
  42. Please note that you'll need to replace `0x123` and `0x456` with the actual setcodes for "titan" and "lightning" cards respectively. You'll also need to replace `10000000` with the actual card code for "lightning-Maria".
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement