name: Snoww,
card_text: If this card is discarded to the GY by card effect: If it was discarded from your hand to your GY by an opponent's card effect, you can target 1 monster in your opponent's GY; add 1 "Dark World" card from your Deck to your hand, then Special Summon that target (if any) in Defense Position.
external_ids: local SETCARD_ID_0 = 0x6 --Dark
  
lua: local SETCARD_ID_0 = 0x6 --Dark
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--search
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_TO_GRAVE)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	e:SetLabel(e:GetHandler():GetPreviousControler())
  	return e:GetHandler():IsPreviousLocation(LOCATION_HAND) and bit.band(r, 0x4040) == 0x4040
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(1 - tp) and chkc:IsLocation(LOCATION_GRAVE) and s.filter2(chkc, e, tp)
  	end
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  	if
  		rp == 1 - tp
  		and tp == e:GetLabel()
  		and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  		and Duel.IsExistingTarget(s.filter2, tp, 0, LOCATION_GRAVE, 1, nil, e, tp)
  		and Duel.SelectYesNo(tp, aux.Stringid(id, 1))
  	then
  		e:SetProperty(EFFECT_FLAG_CARD_TARGET)
  		e:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH + CATEGORY_SPECIAL_SUMMON)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local g = Duel.SelectTarget(tp, s.filter2, tp, 0, LOCATION_GRAVE, 1, 1, nil, e, tp)
  		Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
  	else
  		e:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	end
  end
  function s.filter1(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsAbleToHand()
  end
  function s.filter2(c, e, tp)
  	return c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.filter1, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  		local tc = Duel.GetFirstTarget()
  		if tc and tc:IsRelateToEffect(e) then
  			Duel.BreakEffect()
  			Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP_DEFENSE)
  		end
  	end
  end
  
  
source_text: Snoww,
  If this card is discarded to the GY by card effect: If it was discarded from your hand to your GY by an opponent's card effect, you can target 1 monster in your opponent's GY; add 1 "Dark World" card from your Deck to your hand, then Special Summon that target (if any) in Defense Position.
target_text: -- Snoww,
  local SETCARD_ID_0 = 0x6 --Dark
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--search
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e1:SetCode(EVENT_TO_GRAVE)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.operation)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	e:SetLabel(e:GetHandler():GetPreviousControler())
  	return e:GetHandler():IsPreviousLocation(LOCATION_HAND) and bit.band(r, 0x4040) == 0x4040
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(1 - tp) and chkc:IsLocation(LOCATION_GRAVE) and s.filter2(chkc, e, tp)
  	end
  	if chk == 0 then
  		return true
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  	if
  		rp == 1 - tp
  		and tp == e:GetLabel()
  		and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  		and Duel.IsExistingTarget(s.filter2, tp, 0, LOCATION_GRAVE, 1, nil, e, tp)
  		and Duel.SelectYesNo(tp, aux.Stringid(id, 1))
  	then
  		e:SetProperty(EFFECT_FLAG_CARD_TARGET)
  		e:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH + CATEGORY_SPECIAL_SUMMON)
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  		local g = Duel.SelectTarget(tp, s.filter2, tp, 0, LOCATION_GRAVE, 1, 1, nil, e, tp)
  		Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
  	else
  		e:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	end
  end
  function s.filter1(c)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsAbleToHand()
  end
  function s.filter2(c, e, tp)
  	return c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE)
  end
  function s.operation(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.filter1, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  		local tc = Duel.GetFirstTarget()
  		if tc and tc:IsRelateToEffect(e) then
  			Duel.BreakEffect()
  			Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP_DEFENSE)
  		end
  	end
  end
  
  