FANDOM


LOOP()()Edit

LOOP is a Parenthesized Command which represents an effect that must repeat itself until other parts in the script tell it to stop.

Basic FormEdit

LOOP ( --Effects here---) UNTIL (---Conditions here---)


Detailed ExplanationEdit

Effects in LOOP repeat themselves over and over again. The script alternates between looping effects, checking conditions, looping effects, checking conditions, and so on.

The Condition must check game states. It cannot be a Trigger condition.


ExampleEdit

Magical Merchant  (needs link)


Condition Trigger

CHANGE Me TO Face:Up

Action Trigger
LOOP Area:Deck STARTINGWITH AreaMod:Top STORE CardVar UNTIL (CHECK CardVar.Attr IS Attr:Spell Or Attr:Trap)
(
REVEAL CardVar CAUSE Method:Excavate APPEND AllCardsVar
)
Condition
CHECK CardVar.Attr IS Attr:Spell Or Attr:Trap
Action
MOVE CardVar FROM Area:Deck TO Area:Hand CAUSE Method:Add
MOVE AllCardsVar, !CardVar FROM Area:Deck TO Area:Grave CAUSE Method:Send

Comments on ExampleEdit

This example is more difficult so here are comments on the effects.

The effect activates when the trigger condition is met - the card is flipped face-up

The action is, cards will continually be revealed from the top of the deck ("excavated"). Each individual card is stored in CardVar, but a list of ALL the cards revealed is stored (APPEND) in AllCardsVar.

If STORE is used on a variable that is already remembering a card, it will forget it. But with APPEND, the card is just added into the variable.

Range:Next means that it checks the next card to be revealed. This is what it means in this context. Range:Next has no meaning outside of loops.

The UNTIL condition checks if the Card revealed was a Spell or a Trap. When it is, the loop will be exited.

We check one more time if the card is a Spell or Trap. This is because if the action cannot be done (there are no cards left in the deck), the loop will exit automatically. This is to make sure it exited because the card was a Spell or a Trap, not because there are no cards left in the deck.

The final action is to add the card to the hand, and send the remaining cards to the graveyard. Notice !CardVar must be added to exclude the Spell/Trap card from getting sent to the graveyard.