name: ZS
card_text: If the only monster you control is 1 Level 4 monster not named "ZS - Armed Sage", you can Special Summon this card (from your hand). A "Utopia" Xyz Monster that was Summoned using this card on the field as material gains this effect.
  ● If this card is Xyz Summoned: You can add 1 "ZW -" monster from your Deck to your hand.
  You can only use this effect of "ZS - Armed Sage" once per turn.
external_ids: local SETCARD_ID_0 = 0x107f --Utopia
  local SETCARD_ID_1 = 0x107e --ZW
  
lua: local SETCARD_ID_0 = 0x107f --Utopia
  local SETCARD_ID_1 = 0x107e --ZW
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Special Summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCondition(s.sprcon)
  	c:RegisterEffect(e1)
  	--Gains Effect
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_BE_MATERIAL)
  	e2:SetProperty(EFFECT_FLAG_EVENT_PLAYER)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.efcon)
  	e2:SetOperation(s.efop)
  	c:RegisterEffect(e2)
  end
  function s.sprcon(e, c)
  	if c == nil then
  		return true
  	end
  	local g = Duel.GetFieldGroup(c:GetControler(), LOCATION_MZONE, 0)
  	local tc = g:GetFirst()
  	return #g == 1 and tc:IsFaceup() and tc:IsLevel(4) and not tc:IsCode(id)
  end
  function s.efcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return r == REASON_XYZ and c:GetReasonCard():IsSetCard(SETCARD_ID_1)
  end
  function s.efop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local rc = c:GetReasonCard()
  	local e1 = Effect.CreateEffect(rc)
  	e1:SetDescription(aux.Stringid(id, 1))
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e1:SetType(EFFECT_TYPE_TRIGGER_O + EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetTarget(s.thtg)
  	e1:SetOperation(s.thop)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	rc:RegisterEffect(e1, true)
  	if not rc:IsType(TYPE_EFFECT) then
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_ADD_TYPE)
  		e2:SetValue(TYPE_EFFECT)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  		rc:RegisterEffect(e2, true)
  	end
  end
  function s.thfilter(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.Hint(HINT_OPSELECTED, 1 - tp, e:GetDescription())
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  
  
source_text: ZS
  If the only monster you control is 1 Level 4 monster not named "ZS - Armed Sage", you can Special Summon this card (from your hand). A "Utopia" Xyz Monster that was Summoned using this card on the field as material gains this effect.
  ● If this card is Xyz Summoned: You can add 1 "ZW -" monster from your Deck to your hand.
  You can only use this effect of "ZS - Armed Sage" once per turn.
target_text: -- ZS
  local SETCARD_ID_0 = 0x107f --Utopia
  local SETCARD_ID_1 = 0x107e --ZW
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Special Summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCondition(s.sprcon)
  	c:RegisterEffect(e1)
  	--Gains Effect
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
  	e2:SetCode(EVENT_BE_MATERIAL)
  	e2:SetProperty(EFFECT_FLAG_EVENT_PLAYER)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.efcon)
  	e2:SetOperation(s.efop)
  	c:RegisterEffect(e2)
  end
  function s.sprcon(e, c)
  	if c == nil then
  		return true
  	end
  	local g = Duel.GetFieldGroup(c:GetControler(), LOCATION_MZONE, 0)
  	local tc = g:GetFirst()
  	return #g == 1 and tc:IsFaceup() and tc:IsLevel(4) and not tc:IsCode(id)
  end
  function s.efcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return r == REASON_XYZ and c:GetReasonCard():IsSetCard(SETCARD_ID_1)
  end
  function s.efop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local rc = c:GetReasonCard()
  	local e1 = Effect.CreateEffect(rc)
  	e1:SetDescription(aux.Stringid(id, 1))
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
  	e1:SetType(EFFECT_TYPE_TRIGGER_O + EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetTarget(s.thtg)
  	e1:SetOperation(s.thop)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  	rc:RegisterEffect(e1, true)
  	if not rc:IsType(TYPE_EFFECT) then
  		local e2 = Effect.CreateEffect(c)
  		e2:SetType(EFFECT_TYPE_SINGLE)
  		e2:SetCode(EFFECT_ADD_TYPE)
  		e2:SetValue(TYPE_EFFECT)
  		e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  		rc:RegisterEffect(e2, true)
  	end
  end
  function s.thfilter(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand()
  end
  function s.thtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.thfilter, tp, LOCATION_DECK, 0, 1, nil)
  	end
  	Duel.Hint(HINT_OPSELECTED, 1 - tp, e:GetDescription())
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
  end
  function s.thop(e, tp, eg, ep, ev, re, r, rp)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectMatchingCard(tp, s.thfilter, tp, LOCATION_DECK, 0, 1, 1, nil)
  	if g:GetCount() > 0 then
  		Duel.SendtoHand(g, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, g)
  	end
  end
  
  