name: Onomatopaira
card_text: You can only activate 1 "Onomatopaira" per turn. Send 1 card from your hand to the GY; add up to 2 of these monsters from your Deck to your hand (you cannot add 2 from the same category).
  ● 1 "Zubaba" monster
  ● 1 "Gagaga" monster
  ● 1 "Gogogo" monster
  ● 1 "Dododo" monster
external_ids: local SETCARD_ID_0 = 0x54 --Gagaga
  
lua: local SETCARD_ID_0 = 0x54 --Gagaga
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsAbleToGraveAsCost, tp, LOCATION_HAND, 0, 1, e:GetHandler())
  	end
  	Duel.DiscardHand(tp, Card.IsAbleToGraveAsCost, 1, 1, REASON_COST)
  end
  function s.filter(c)
  	return c:IsType(TYPE_MONSTER) and c:IsSetCard(SETCARD_ID_0, 0x59, 0x82, 0x8f) and c:IsAbleToHand()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.check(g)
  	if #g == 1 then
  		return true
  	end
  	local res = 0x0
  	if g:IsExists(Card.IsSetCard, 1, nil, 0x54) then
  		res = res + 0x1
  	end
  	if g:IsExists(Card.IsSetCard, 1, nil, 0x59) then
  		res = res + 0x2
  	end
  	if g:IsExists(Card.IsSetCard, 1, nil, 0x82) then
  		res = res + 0x4
  	end
  	if g:IsExists(Card.IsSetCard, 1, nil, 0x8f) then
  		res = res + 0x8
  	end
  	return res ~= 0x1 and res ~= 0x2 and res ~= 0x4 and res ~= 0x8
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_DECK, 0, nil)
  	if g:GetCount() == 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g1 = g:SelectSubGroup(tp, s.check, false, 1, 2)
  	Duel.SendtoHand(g1, nil, REASON_EFFECT)
  	Duel.ConfirmCards(1 - tp, g1)
  end
  
  
source_text: Onomatopaira
  You can only activate 1 "Onomatopaira" per turn. Send 1 card from your hand to the GY; add up to 2 of these monsters from your Deck to your hand (you cannot add 2 from the same category).
  ● 1 "Zubaba" monster
  ● 1 "Gagaga" monster
  ● 1 "Gogogo" monster
  ● 1 "Dododo" monster
target_text: -- Onomatopaira
  local SETCARD_ID_0 = 0x54 --Gagaga
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(Card.IsAbleToGraveAsCost, tp, LOCATION_HAND, 0, 1, e:GetHandler())
  	end
  	Duel.DiscardHand(tp, Card.IsAbleToGraveAsCost, 1, 1, REASON_COST)
  end
  function s.filter(c)
  	return c:IsType(TYPE_MONSTER) and c:IsSetCard(SETCARD_ID_0, 0x59, 0x82, 0x8f) and c:IsAbleToHand()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.check(g)
  	if #g == 1 then
  		return true
  	end
  	local res = 0x0
  	if g:IsExists(Card.IsSetCard, 1, nil, 0x54) then
  		res = res + 0x1
  	end
  	if g:IsExists(Card.IsSetCard, 1, nil, 0x59) then
  		res = res + 0x2
  	end
  	if g:IsExists(Card.IsSetCard, 1, nil, 0x82) then
  		res = res + 0x4
  	end
  	if g:IsExists(Card.IsSetCard, 1, nil, 0x8f) then
  		res = res + 0x8
  	end
  	return res ~= 0x1 and res ~= 0x2 and res ~= 0x4 and res ~= 0x8
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetMatchingGroup(s.filter, tp, LOCATION_DECK, 0, nil)
  	if g:GetCount() == 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g1 = g:SelectSubGroup(tp, s.check, false, 1, 2)
  	Duel.SendtoHand(g1, nil, REASON_EFFECT)
  	Duel.ConfirmCards(1 - tp, g1)
  end
  
  