name: Longirsu,
card_text: 2+ Effect Monsters, including an "Orcust" monster
  This linked card cannot be destroyed by card effects. You can target 2 of your banished Machine monsters; shuffle them into the Deck, then you can send 1 linked monster your opponent controls to the GY. This card cannot attack the turn you activate this effect. You can only use this effect of "Longirsu, the Orcust Orchestrator" once per turn.
external_ids: local CARD_ID_0 = 90351981 --Orcustrated Babel
  
lua: local CARD_ID_0 = 90351981 --Orcustrated Babel
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkType, TYPE_EFFECT), 2, 99, s.lcheck)
  	c:EnableReviveLimit()
  	--indes
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  	e1:SetCondition(s.indcon)
  	e1:SetValue(1)
  	c:RegisterEffect(e1)
  	--todeck
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_TODECK + CATEGORY_TOGRAVE)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.tdcon1)
  	e2:SetCost(s.tdcost)
  	e2:SetTarget(s.tdtg)
  	e2:SetOperation(s.tdop)
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetType(EFFECT_TYPE_QUICK_O)
  	e3:SetCode(EVENT_FREE_CHAIN)
  	e3:SetHintTiming(0, TIMINGS_CHECK_MONSTER)
  	e3:SetCondition(s.tdcon2)
  	c:RegisterEffect(e3)
  end
  function s.lcheck(g)
  	return g:IsExists(Card.IsLinkSetCard, 1, nil, 0x11b)
  end
  function s.indcon(e)
  	return e:GetHandler():IsLinkState()
  end
  function s.tdcon1(e, tp, eg, ep, ev, re, r, rp)
  	return not aux.IsCanBeQuickEffect(e:GetHandler(), tp, CARD_ID_0)
  end
  function s.tdcon2(e, tp, eg, ep, ev, re, r, rp)
  	return aux.IsCanBeQuickEffect(e:GetHandler(), tp, CARD_ID_0)
  end
  function s.tdcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():GetAttackAnnouncedCount() == 0
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_OATH)
  	e1:SetCode(EFFECT_CANNOT_ATTACK)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  	e:GetHandler():RegisterEffect(e1)
  end
  function s.tdfilter(c)
  	return c:IsFaceup() and c:IsRace(RACE_MACHINE) and c:IsAbleToDeck()
  end
  function s.tdtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_REMOVED) and chkc:IsControler(tp) and s.tdfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.tdfilter, tp, LOCATION_REMOVED, 0, 2, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  	local g = Duel.SelectTarget(tp, s.tdfilter, tp, LOCATION_REMOVED, 0, 2, 2, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, g, 2, 0, 0)
  end
  function s.tdop(e, tp, eg, ep, ev, re, r, rp)
  	local tg = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect, nil, e)
  	if tg:GetCount() > 0 and Duel.SendtoDeck(tg, nil, SEQ_DECKSHUFFLE, REASON_EFFECT) ~= 0 and tg:IsExists(Card.IsLocation, 1, nil, LOCATION_DECK + LOCATION_EXTRA) then
  		local g = Duel.GetMatchingGroup(Card.IsLinkState, tp, 0, LOCATION_MZONE, nil)
  		if g:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 1)) then
  			Duel.BreakEffect()
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  			local sg = g:Select(tp, 1, 1, nil)
  			Duel.SendtoGrave(sg, REASON_EFFECT)
  		end
  	end
  end
  
  
source_text: Longirsu,
  2+ Effect Monsters, including an "Orcust" monster
  This linked card cannot be destroyed by card effects. You can target 2 of your banished Machine monsters; shuffle them into the Deck, then you can send 1 linked monster your opponent controls to the GY. This card cannot attack the turn you activate this effect. You can only use this effect of "Longirsu, the Orcust Orchestrator" once per turn.
target_text: -- Longirsu,
  local CARD_ID_0 = 90351981 --Orcustrated Babel
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkType, TYPE_EFFECT), 2, 99, s.lcheck)
  	c:EnableReviveLimit()
  	--indes
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  	e1:SetCondition(s.indcon)
  	e1:SetValue(1)
  	c:RegisterEffect(e1)
  	--todeck
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_TODECK + CATEGORY_TOGRAVE)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetCondition(s.tdcon1)
  	e2:SetCost(s.tdcost)
  	e2:SetTarget(s.tdtg)
  	e2:SetOperation(s.tdop)
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetType(EFFECT_TYPE_QUICK_O)
  	e3:SetCode(EVENT_FREE_CHAIN)
  	e3:SetHintTiming(0, TIMINGS_CHECK_MONSTER)
  	e3:SetCondition(s.tdcon2)
  	c:RegisterEffect(e3)
  end
  function s.lcheck(g)
  	return g:IsExists(Card.IsLinkSetCard, 1, nil, 0x11b)
  end
  function s.indcon(e)
  	return e:GetHandler():IsLinkState()
  end
  function s.tdcon1(e, tp, eg, ep, ev, re, r, rp)
  	return not aux.IsCanBeQuickEffect(e:GetHandler(), tp, CARD_ID_0)
  end
  function s.tdcon2(e, tp, eg, ep, ev, re, r, rp)
  	return aux.IsCanBeQuickEffect(e:GetHandler(), tp, CARD_ID_0)
  end
  function s.tdcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():GetAttackAnnouncedCount() == 0
  	end
  	local e1 = Effect.CreateEffect(e:GetHandler())
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_OATH)
  	e1:SetCode(EFFECT_CANNOT_ATTACK)
  	e1:SetReset(RESET_EVENT + RESETS_STANDARD + RESET_PHASE + PHASE_END)
  	e:GetHandler():RegisterEffect(e1)
  end
  function s.tdfilter(c)
  	return c:IsFaceup() and c:IsRace(RACE_MACHINE) and c:IsAbleToDeck()
  end
  function s.tdtg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_REMOVED) and chkc:IsControler(tp) and s.tdfilter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.tdfilter, tp, LOCATION_REMOVED, 0, 2, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
  	local g = Duel.SelectTarget(tp, s.tdfilter, tp, LOCATION_REMOVED, 0, 2, 2, nil)
  	Duel.SetOperationInfo(0, CATEGORY_TODECK, g, 2, 0, 0)
  end
  function s.tdop(e, tp, eg, ep, ev, re, r, rp)
  	local tg = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect, nil, e)
  	if tg:GetCount() > 0 and Duel.SendtoDeck(tg, nil, SEQ_DECKSHUFFLE, REASON_EFFECT) ~= 0 and tg:IsExists(Card.IsLocation, 1, nil, LOCATION_DECK + LOCATION_EXTRA) then
  		local g = Duel.GetMatchingGroup(Card.IsLinkState, tp, 0, LOCATION_MZONE, nil)
  		if g:GetCount() > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 1)) then
  			Duel.BreakEffect()
  			Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  			local sg = g:Select(tp, 1, 1, nil)
  			Duel.SendtoGrave(sg, REASON_EFFECT)
  		end
  	end
  end
  
  