name: クリボーを呼ぶ笛
card_text: 自分のデッキから「クリボー」または「ハネクリボー」1体を選択し、手札に加えるか自分フィールド上に特殊召喚する事ができる。
external_ids: local CARD_ID_0 = 40640057 --クリボー
  local CARD_ID_1 = 57116033 --ハネクリボー
  
lua: local CARD_ID_0 = 40640057 --クリボー
  local CARD_ID_1 = 57116033 --ハネクリボー
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH + CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter(c, ft, e, tp)
  	return c:IsCode(CARD_ID_0, CARD_ID_1) and (c:IsAbleToHand() or (ft > 0 and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)))
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_DECK, 0, 1, nil, ft, e, tp)
  	end
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_OPERATECARD)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_DECK, 0, 1, 1, nil, ft, e, tp)
  	if g:GetCount() > 0 then
  		local th = g:GetFirst():IsAbleToHand()
  		local sp = ft > 0 and g:GetFirst():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  		local op = 0
  		if th and sp then
  			op = Duel.SelectOption(tp, 1190, 1152)
  		elseif th then
  			op = 0
  		else
  			op = 1
  		end
  		if op == 0 then
  			Duel.SendtoHand(g, nil, REASON_EFFECT)
  			Duel.ConfirmCards(1 - tp, g)
  		else
  			Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  		end
  	end
  end
  
  
source_text: クリボーを呼ぶ笛
  自分のデッキから「クリボー」または「ハネクリボー」1体を選択し、手札に加えるか自分フィールド上に特殊召喚する事ができる。
target_text: -- クリボーを呼ぶ笛
  local CARD_ID_0 = 40640057 --クリボー
  local CARD_ID_1 = 57116033 --ハネクリボー
  local s, id, o = GetID()
  function s.initial_effect(c)
  	aux.AddCodeList(c, CARD_ID_0)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH + CATEGORY_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.filter(c, ft, e, tp)
  	return c:IsCode(CARD_ID_0, CARD_ID_1) and (c:IsAbleToHand() or (ft > 0 and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)))
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_DECK, 0, 1, nil, ft, e, tp)
  	end
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_OPERATECARD)
  	local g = Duel.SelectMatchingCard(tp, s.filter, tp, LOCATION_DECK, 0, 1, 1, nil, ft, e, tp)
  	if g:GetCount() > 0 then
  		local th = g:GetFirst():IsAbleToHand()
  		local sp = ft > 0 and g:GetFirst():IsCanBeSpecialSummoned(e, 0, tp, false, false)
  		local op = 0
  		if th and sp then
  			op = Duel.SelectOption(tp, 1190, 1152)
  		elseif th then
  			op = 0
  		else
  			op = 1
  		end
  		if op == 0 then
  			Duel.SendtoHand(g, nil, REASON_EFFECT)
  			Duel.ConfirmCards(1 - tp, g)
  		else
  			Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  		end
  	end
  end
  
  