name: Daidaratant
card_text: Pendulum Scale = 3
  [ Pendulum Effect ]
  You can target 1 Xyz Monster you control; attach this card to it as material. You can only use this effect of "Daidaratant the Ooze Giant" once per turn.
  ----------------------------------------
  [ Monster Effect ]
  2 Level 4 monsters
  If you can Pendulum Summon Level 4, you can Pendulum Summon this face-up card from your Extra Deck. You can detach 1 material from this card; place this card in your Pendulum Zone, then you can add 1 Pendulum Monster from your GY to the Extra Deck face-up. If this card in the Monster Zone is destroyed by battle or card effect: You can place this card in your Pendulum Zone. You can only use each effect of "Daidaratant the Ooze Giant" once per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 4, 2)
  	c:EnableReviveLimit()
  	--pendulum summon
  	aux.EnablePendulumAttribute(c, false)
  	--xyz material
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_PZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.xyztg)
  	e1:SetOperation(s.xyzop)
  	c:RegisterEffect(e1)
  	--pzone move 1
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCost(s.pencost1)
  	e2:SetTarget(s.pentg)
  	e2:SetOperation(s.penop1)
  	c:RegisterEffect(e2)
  	--pzone move 2
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 2))
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_DESTROYED)
  	e3:SetProperty(EFFECT_FLAG_DELAY)
  	e3:SetCountLimit(1, id + 2)
  	e3:SetCondition(s.pencon2)
  	e3:SetTarget(s.pentg)
  	e3:SetOperation(s.penop2)
  	c:RegisterEffect(e3)
  end
  s.pendulum_level = 4
  function s.filter(c)
  	return c:IsFaceup() and c:IsType(TYPE_XYZ)
  end
  function s.xyztg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, 0, 1, nil) and e:GetHandler():IsCanOverlay()
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  end
  function s.xyzop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if not tc:IsImmuneToEffect(e) and tc:IsRelateToEffect(e) and c:IsRelateToEffect(e) and c:IsCanOverlay() then
  		Duel.Overlay(tc, Group.FromCards(c))
  	end
  end
  function s.pencost1(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
  end
  function s.pentg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckLocation(tp, LOCATION_PZONE, 0) or Duel.CheckLocation(tp, LOCATION_PZONE, 1)
  	end
  end
  function s.pmfilter(c)
  	return c:IsType(TYPE_PENDULUM)
  end
  function s.penop1(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) or not Duel.MoveToField(c, tp, tp, LOCATION_PZONE, POS_FACEUP, true) then
  		return
  	end
  	if Duel.IsExistingMatchingCard(aux.NecroValleyFilter(s.pmfilter), tp, LOCATION_GRAVE, 0, 1, nil) and Duel.SelectYesNo(tp, aux.Stringid(id, 3)) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  		local g = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.pmfilter), tp, LOCATION_GRAVE, 0, 1, 1, nil)
  		Duel.BreakEffect()
  		Duel.SendtoExtraP(g, nil, REASON_EFFECT)
  	end
  end
  function s.pencon2(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsReason(REASON_BATTLE + REASON_EFFECT) and c:IsPreviousLocation(LOCATION_MZONE)
  end
  function s.penop2(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	Duel.MoveToField(c, tp, tp, LOCATION_PZONE, POS_FACEUP, true)
  end
  
  
source_text: Daidaratant
  Pendulum Scale = 3
  [ Pendulum Effect ]
  You can target 1 Xyz Monster you control; attach this card to it as material. You can only use this effect of "Daidaratant the Ooze Giant" once per turn.
  ----------------------------------------
  [ Monster Effect ]
  2 Level 4 monsters
  If you can Pendulum Summon Level 4, you can Pendulum Summon this face-up card from your Extra Deck. You can detach 1 material from this card; place this card in your Pendulum Zone, then you can add 1 Pendulum Monster from your GY to the Extra Deck face-up. If this card in the Monster Zone is destroyed by battle or card effect: You can place this card in your Pendulum Zone. You can only use each effect of "Daidaratant the Ooze Giant" once per turn.
target_text: -- Daidaratant
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--xyz summon
  	aux.AddXyzProcedure(c, nil, 4, 2)
  	c:EnableReviveLimit()
  	--pendulum summon
  	aux.EnablePendulumAttribute(c, false)
  	--xyz material
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetRange(LOCATION_PZONE)
  	e1:SetCountLimit(1, id)
  	e1:SetTarget(s.xyztg)
  	e1:SetOperation(s.xyzop)
  	c:RegisterEffect(e1)
  	--pzone move 1
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCost(s.pencost1)
  	e2:SetTarget(s.pentg)
  	e2:SetOperation(s.penop1)
  	c:RegisterEffect(e2)
  	--pzone move 2
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 2))
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetCode(EVENT_DESTROYED)
  	e3:SetProperty(EFFECT_FLAG_DELAY)
  	e3:SetCountLimit(1, id + 2)
  	e3:SetCondition(s.pencon2)
  	e3:SetTarget(s.pentg)
  	e3:SetOperation(s.penop2)
  	c:RegisterEffect(e3)
  end
  s.pendulum_level = 4
  function s.filter(c)
  	return c:IsFaceup() and c:IsType(TYPE_XYZ)
  end
  function s.xyztg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, 0, 1, nil) and e:GetHandler():IsCanOverlay()
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 1, nil)
  end
  function s.xyzop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if not tc:IsImmuneToEffect(e) and tc:IsRelateToEffect(e) and c:IsRelateToEffect(e) and c:IsCanOverlay() then
  		Duel.Overlay(tc, Group.FromCards(c))
  	end
  end
  function s.pencost1(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():CheckRemoveOverlayCard(tp, 1, REASON_COST)
  	end
  	e:GetHandler():RemoveOverlayCard(tp, 1, 1, REASON_COST)
  end
  function s.pentg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.CheckLocation(tp, LOCATION_PZONE, 0) or Duel.CheckLocation(tp, LOCATION_PZONE, 1)
  	end
  end
  function s.pmfilter(c)
  	return c:IsType(TYPE_PENDULUM)
  end
  function s.penop1(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) or not Duel.MoveToField(c, tp, tp, LOCATION_PZONE, POS_FACEUP, true) then
  		return
  	end
  	if Duel.IsExistingMatchingCard(aux.NecroValleyFilter(s.pmfilter), tp, LOCATION_GRAVE, 0, 1, nil) and Duel.SelectYesNo(tp, aux.Stringid(id, 3)) then
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  		local g = Duel.SelectMatchingCard(tp, aux.NecroValleyFilter(s.pmfilter), tp, LOCATION_GRAVE, 0, 1, 1, nil)
  		Duel.BreakEffect()
  		Duel.SendtoExtraP(g, nil, REASON_EFFECT)
  	end
  end
  function s.pencon2(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsReason(REASON_BATTLE + REASON_EFFECT) and c:IsPreviousLocation(LOCATION_MZONE)
  end
  function s.penop2(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not c:IsRelateToEffect(e) then
  		return
  	end
  	Duel.MoveToField(c, tp, tp, LOCATION_PZONE, POS_FACEUP, true)
  end
  
  