name: Cry
card_text: You can remove from play 1 monster from your Graveyard to Normal Summon or Set 1 Normal Monster from your hand. You can only activate this effect during your Main Phase.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_SUMMON)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetCondition(s.condition)
  	e2:SetCost(s.cost)
  	e2:SetTarget(s.target)
  	e2:SetOperation(s.activate)
  	c:RegisterEffect(e2)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	local tn = Duel.GetTurnPlayer()
  	local ph = Duel.GetCurrentPhase()
  	return tn == tp and (ph == PHASE_MAIN1 or ph == PHASE_MAIN2)
  end
  function s.cfilter(c)
  	return c:IsType(TYPE_MONSTER) and c:IsAbleToRemoveAsCost()
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.Remove(g, POS_FACEUP, REASON_COST)
  end
  function s.filter(c)
  	return c:IsType(TYPE_NORMAL) and (c:IsSummonable(true, nil) or c:IsMSetable(true, nil))
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		local ct1 = Duel.GetMatchingGroupCount(s.filter, tp, LOCATION_HAND, 0, nil)
  		local ct2 = Duel.GetFlagEffect(tp, id)
  		return ct1 - ct2 > 0
  	end
  	Duel.RegisterFlagEffect(tp, id, RESET_CHAIN, 0, 1)
  	Duel.SetOperationInfo(0, CATEGORY_SUMMON, nil, 1, 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_HAND, 0, 1, 1, nil)
  	local tc = g:GetFirst()
  	if tc then
  		local s1 = tc:IsSummonable(true, nil)
  		local s2 = tc:IsMSetable(true, nil)
  		if (s1 and s2 and Duel.SelectPosition(tp, tc, POS_FACEUP_ATTACK + POS_FACEDOWN_DEFENSE) == POS_FACEUP_ATTACK) or not s2 then
  			Duel.Summon(tp, tc, true, nil)
  		else
  			Duel.MSet(tp, tc, true, nil)
  		end
  	end
  end
  
  
source_text: Cry
  You can remove from play 1 monster from your Graveyard to Normal Summon or Set 1 Normal Monster from your hand. You can only activate this effect during your Main Phase.
target_text: -- Cry
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	c:RegisterEffect(e1)
  	--summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_SUMMON)
  	e2:SetType(EFFECT_TYPE_QUICK_O)
  	e2:SetRange(LOCATION_SZONE)
  	e2:SetCode(EVENT_FREE_CHAIN)
  	e2:SetCondition(s.condition)
  	e2:SetCost(s.cost)
  	e2:SetTarget(s.target)
  	e2:SetOperation(s.activate)
  	c:RegisterEffect(e2)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	local tn = Duel.GetTurnPlayer()
  	local ph = Duel.GetCurrentPhase()
  	return tn == tp and (ph == PHASE_MAIN1 or ph == PHASE_MAIN2)
  end
  function s.cfilter(c)
  	return c:IsType(TYPE_MONSTER) and c:IsAbleToRemoveAsCost()
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.cfilter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_REMOVE)
  	local g = Duel.SelectMatchingCard(tp, s.cfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	Duel.Remove(g, POS_FACEUP, REASON_COST)
  end
  function s.filter(c)
  	return c:IsType(TYPE_NORMAL) and (c:IsSummonable(true, nil) or c:IsMSetable(true, nil))
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		local ct1 = Duel.GetMatchingGroupCount(s.filter, tp, LOCATION_HAND, 0, nil)
  		local ct2 = Duel.GetFlagEffect(tp, id)
  		return ct1 - ct2 > 0
  	end
  	Duel.RegisterFlagEffect(tp, id, RESET_CHAIN, 0, 1)
  	Duel.SetOperationInfo(0, CATEGORY_SUMMON, nil, 1, 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_HAND, 0, 1, 1, nil)
  	local tc = g:GetFirst()
  	if tc then
  		local s1 = tc:IsSummonable(true, nil)
  		local s2 = tc:IsMSetable(true, nil)
  		if (s1 and s2 and Duel.SelectPosition(tp, tc, POS_FACEUP_ATTACK + POS_FACEDOWN_DEFENSE) == POS_FACEUP_ATTACK) or not s2 then
  			Duel.Summon(tp, tc, true, nil)
  		else
  			Duel.MSet(tp, tc, true, nil)
  		end
  	end
  end
  
  