name: Mekk-Knight
card_text: 2+ "Mekk-Knight" monsters
  This card can attack directly if it is the only card in its column. If this card in the Extra Monster Zone points to no monsters, it cannot be destroyed by card effects, also your opponent cannot target it with card effects. You can send 1 other card you control in this card's column to the GY: Special Summon 1 "Mekk-Knight" monster from your Deck in Defense Position. You can only use this effect of "Mekk-Knight Spectrum Supreme" once per turn.
external_ids: local SETCARD_ID_0 = 0x10c --Mekk-Knight
  
lua: local SETCARD_ID_0 = 0x10c --Mekk-Knight
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkSetCard, SETCARD_ID_0), 2)
  	--direct attack
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_DIRECT_ATTACK)
  	e1:SetCondition(s.dircon)
  	c:RegisterEffect(e1)
  	--cannot be target/effect indestructable
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCondition(s.indcon)
  	e2:SetValue(1)
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  	e3:SetValue(aux.tgoval)
  	c:RegisterEffect(e3)
  	--special summon
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 0))
  	e4:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e4:SetType(EFFECT_TYPE_IGNITION)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetCountLimit(1, id)
  	e4:SetCost(s.spcost)
  	e4:SetTarget(s.sptg)
  	e4:SetOperation(s.spop)
  	c:RegisterEffect(e4)
  end
  function s.dircon(e)
  	return e:GetHandler():GetColumnGroupCount() == 0
  end
  function s.indcon(e)
  	local c = e:GetHandler()
  	return c:GetSequence() > 4 and c:IsType(TYPE_LINK) and c:GetLinkedGroupCount() == 0
  end
  function s.spcfilter(c, g, tp)
  	return g:IsContains(c) and c:IsAbleToGraveAsCost() and Duel.GetMZoneCount(tp, c) > 0
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE)
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	local cg = c:GetColumnGroup()
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.spcfilter, tp, LOCATION_ONFIELD, 0, 1, c, cg, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.spcfilter, tp, LOCATION_ONFIELD, 0, 1, 1, c, cg, tp)
  	Duel.SendtoGrave(g, REASON_COST)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_DECK, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_DECK, 0, 1, 1, nil, e, tp)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP_DEFENSE)
  	end
  end
  
  
source_text: Mekk-Knight
  2+ "Mekk-Knight" monsters
  This card can attack directly if it is the only card in its column. If this card in the Extra Monster Zone points to no monsters, it cannot be destroyed by card effects, also your opponent cannot target it with card effects. You can send 1 other card you control in this card's column to the GY: Special Summon 1 "Mekk-Knight" monster from your Deck in Defense Position. You can only use this effect of "Mekk-Knight Spectrum Supreme" once per turn.
target_text: -- Mekk-Knight
  local SETCARD_ID_0 = 0x10c --Mekk-Knight
  local s, id, o = GetID()
  function s.initial_effect(c)
  	c:EnableReviveLimit()
  	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkSetCard, SETCARD_ID_0), 2)
  	--direct attack
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_DIRECT_ATTACK)
  	e1:SetCondition(s.dircon)
  	c:RegisterEffect(e1)
  	--cannot be target/effect indestructable
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCondition(s.indcon)
  	e2:SetValue(1)
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
  	e3:SetValue(aux.tgoval)
  	c:RegisterEffect(e3)
  	--special summon
  	local e4 = Effect.CreateEffect(c)
  	e4:SetDescription(aux.Stringid(id, 0))
  	e4:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e4:SetType(EFFECT_TYPE_IGNITION)
  	e4:SetRange(LOCATION_MZONE)
  	e4:SetCountLimit(1, id)
  	e4:SetCost(s.spcost)
  	e4:SetTarget(s.sptg)
  	e4:SetOperation(s.spop)
  	c:RegisterEffect(e4)
  end
  function s.dircon(e)
  	return e:GetHandler():GetColumnGroupCount() == 0
  end
  function s.indcon(e)
  	local c = e:GetHandler()
  	return c:GetSequence() > 4 and c:IsType(TYPE_LINK) and c:GetLinkedGroupCount() == 0
  end
  function s.spcfilter(c, g, tp)
  	return g:IsContains(c) and c:IsAbleToGraveAsCost() and Duel.GetMZoneCount(tp, c) > 0
  end
  function s.spfilter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_DEFENSE)
  end
  function s.spcost(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	local cg = c:GetColumnGroup()
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.spcfilter, tp, LOCATION_ONFIELD, 0, 1, c, cg, tp)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TOGRAVE)
  	local g = Duel.SelectMatchingCard(tp, s.spcfilter, tp, LOCATION_ONFIELD, 0, 1, 1, c, cg, tp)
  	Duel.SendtoGrave(g, REASON_COST)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.spfilter, tp, LOCATION_DECK, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter, tp, LOCATION_DECK, 0, 1, 1, nil, e, tp)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP_DEFENSE)
  	end
  end
  
  