name: Performapal
card_text: Pendulum Scale = 2
  [ Pendulum Effect ]
  Once per turn, when a monster you control inflicts battle damage to your opponent: You can send the top card of your opponent's Deck to the Graveyard.
  ----------------------------------------
  [ Monster Effect ]
  This card can attack your opponent directly. If this card attacks, it is changed to Defense Position at the end of the Battle Phase.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.EnablePendulumAttribute(c)
  	--deckdes
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DECKDES)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_BATTLE_DAMAGE)
  	e1:SetRange(LOCATION_PZONE)
  	e1:SetCountLimit(1)
  	e1:SetCondition(s.ddescon)
  	e1:SetTarget(s.ddestg)
  	e1:SetOperation(s.ddesop)
  	c:RegisterEffect(e1)
  	--direct attack
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_DIRECT_ATTACK)
  	c:RegisterEffect(e2)
  	--change position
  	local e3 = Effect.CreateEffect(c)
  	e3:SetCategory(CATEGORY_POSITION)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e3:SetCode(EVENT_PHASE + PHASE_BATTLE)
  	e3:SetCountLimit(1)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCondition(s.poscon)
  	e3:SetOperation(s.posop)
  	c:RegisterEffect(e3)
  end
  function s.ddescon(e, tp, eg, ep, ev, re, r, rp)
  	return ep ~= tp and eg:GetFirst():IsControler(tp)
  end
  function s.ddestg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDiscardDeck(1 - tp, 1)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DECKDES, 0, 0, 1 - tp, 1)
  end
  function s.ddesop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.DiscardDeck(1 - tp, 1, REASON_EFFECT)
  end
  function s.poscon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():GetAttackedCount() > 0
  end
  function s.posop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsAttackPos() then
  		Duel.ChangePosition(c, POS_FACEUP_DEFENSE)
  	end
  end
  
  
source_text: Performapal
  Pendulum Scale = 2
  [ Pendulum Effect ]
  Once per turn, when a monster you control inflicts battle damage to your opponent: You can send the top card of your opponent's Deck to the Graveyard.
  ----------------------------------------
  [ Monster Effect ]
  This card can attack your opponent directly. If this card attacks, it is changed to Defense Position at the end of the Battle Phase.
target_text: -- Performapal
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.EnablePendulumAttribute(c)
  	--deckdes
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DECKDES)
  	e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_BATTLE_DAMAGE)
  	e1:SetRange(LOCATION_PZONE)
  	e1:SetCountLimit(1)
  	e1:SetCondition(s.ddescon)
  	e1:SetTarget(s.ddestg)
  	e1:SetOperation(s.ddesop)
  	c:RegisterEffect(e1)
  	--direct attack
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_DIRECT_ATTACK)
  	c:RegisterEffect(e2)
  	--change position
  	local e3 = Effect.CreateEffect(c)
  	e3:SetCategory(CATEGORY_POSITION)
  	e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
  	e3:SetCode(EVENT_PHASE + PHASE_BATTLE)
  	e3:SetCountLimit(1)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCondition(s.poscon)
  	e3:SetOperation(s.posop)
  	c:RegisterEffect(e3)
  end
  function s.ddescon(e, tp, eg, ep, ev, re, r, rp)
  	return ep ~= tp and eg:GetFirst():IsControler(tp)
  end
  function s.ddestg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanDiscardDeck(1 - tp, 1)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DECKDES, 0, 0, 1 - tp, 1)
  end
  function s.ddesop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.DiscardDeck(1 - tp, 1, REASON_EFFECT)
  end
  function s.poscon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():GetAttackedCount() > 0
  end
  function s.posop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if c:IsAttackPos() then
  		Duel.ChangePosition(c, POS_FACEUP_DEFENSE)
  	end
  end
  
  