name: Guts
card_text: Select 3 "Scrap" monsters in your Graveyard. Your opponent picks 1 of them, you Special Summon it to either player's side of the field, and remove the rest from play.
external_ids: local SETCARD_ID_0 = 0x24 --Scrap
  
lua: local SETCARD_ID_0 = 0x24 --Scrap
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	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, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and (c:IsCanBeSpecialSummoned(e, 0, tp, false, false) or c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP, 1 - tp))
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.filter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return (Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 or Duel.GetLocationCount(1 - tp, LOCATION_MZONE) > 0) and Duel.IsExistingTarget(s.filter, tp, LOCATION_GRAVE, 0, 3, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 2))
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_GRAVE, 0, 3, 3, nil, e, tp)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect, nil, e)
  	local ft1 = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	local ft2 = Duel.GetLocationCount(1 - tp, LOCATION_MZONE)
  	if g:GetCount() == 0 or (ft1 == 0 and ft2 == 0) then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, 1 - tp, HINTMSG_SPSUMMON)
  	local tc = g:Select(1 - tp, 1, 1, nil):GetFirst()
  	local s1 = ft1 > 0 and tc:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	local s2 = ft2 > 0 and tc:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP, 1 - tp)
  	local op = 0
  	if s1 and s2 then
  		op = Duel.SelectOption(tp, aux.Stringid(id, 0), aux.Stringid(id, 1))
  	elseif s1 then
  		op = Duel.SelectOption(tp, aux.Stringid(id, 0))
  	elseif s2 then
  		op = Duel.SelectOption(tp, aux.Stringid(id, 1)) + 1
  	else
  		op = 2
  	end
  	if op == 0 then
  		Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
  	elseif op == 1 then
  		Duel.SpecialSummon(tc, 0, tp, 1 - tp, false, false, POS_FACEUP)
  	end
  	g:RemoveCard(tc)
  	Duel.Remove(g, POS_FACEUP, REASON_EFFECT)
  end
  
  
source_text: Guts
  Select 3 "Scrap" monsters in your Graveyard. Your opponent picks 1 of them, you Special Summon it to either player's side of the field, and remove the rest from play.
target_text: -- Guts
  local SETCARD_ID_0 = 0x24 --Scrap
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	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, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and (c:IsCanBeSpecialSummoned(e, 0, tp, false, false) or c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP, 1 - tp))
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.filter(chkc, e, tp)
  	end
  	if chk == 0 then
  		return (Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 or Duel.GetLocationCount(1 - tp, LOCATION_MZONE) > 0) and Duel.IsExistingTarget(s.filter, tp, LOCATION_GRAVE, 0, 3, nil, e, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, aux.Stringid(id, 2))
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_GRAVE, 0, 3, 3, nil, e, tp)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, g, 1, 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect, nil, e)
  	local ft1 = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	local ft2 = Duel.GetLocationCount(1 - tp, LOCATION_MZONE)
  	if g:GetCount() == 0 or (ft1 == 0 and ft2 == 0) then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, 1 - tp, HINTMSG_SPSUMMON)
  	local tc = g:Select(1 - tp, 1, 1, nil):GetFirst()
  	local s1 = ft1 > 0 and tc:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  	local s2 = ft2 > 0 and tc:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP, 1 - tp)
  	local op = 0
  	if s1 and s2 then
  		op = Duel.SelectOption(tp, aux.Stringid(id, 0), aux.Stringid(id, 1))
  	elseif s1 then
  		op = Duel.SelectOption(tp, aux.Stringid(id, 0))
  	elseif s2 then
  		op = Duel.SelectOption(tp, aux.Stringid(id, 1)) + 1
  	else
  		op = 2
  	end
  	if op == 0 then
  		Duel.SpecialSummon(tc, 0, tp, tp, false, false, POS_FACEUP)
  	elseif op == 1 then
  		Duel.SpecialSummon(tc, 0, tp, 1 - tp, false, false, POS_FACEUP)
  	end
  	g:RemoveCard(tc)
  	Duel.Remove(g, POS_FACEUP, REASON_EFFECT)
  end
  
  