name: Mekk-Knight
card_text: If 2 or more cards are in the same column, you can Special Summon this card (from your hand) in that column. You can only Special Summon "Mekk-Knight Orange Sunset" once per turn this way. If an opponent's card in this card's column is destroyed by battle, or leaves the field: You can Special Summon 1 "Mekk-Knight" monster from your hand.
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)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCondition(s.hspcon)
  	e1:SetValue(s.hspval)
  	c:RegisterEffect(e1)
  	--spsummon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_LEAVE_FIELD)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_DAMAGE_STEP)
  	e2:SetCondition(s.spcon)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c)
  	return c:GetColumnGroupCount() > 0
  end
  function s.hspcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	local zone = 0
  	local lg = Duel.GetMatchingGroup(s.cfilter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, nil)
  	for tc in aux.Next(lg) do
  		zone = bit.bor(zone, tc:GetColumnZone(LOCATION_MZONE, tp))
  	end
  	return Duel.GetLocationCount(tp, LOCATION_MZONE, tp, LOCATION_REASON_TOFIELD, zone) > 0
  end
  function s.hspval(e, c)
  	local tp = c:GetControler()
  	local zone = 0
  	local lg = Duel.GetMatchingGroup(s.cfilter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, nil)
  	for tc in aux.Next(lg) do
  		zone = bit.bor(zone, tc:GetColumnZone(LOCATION_MZONE, tp))
  	end
  	return 0, zone
  end
  function s.spcfilter(c, tp, mc)
  	if c:IsPreviousControler(tp) then
  		return false
  	end
  	local zone = mc:GetColumnZone(LOCATION_ONFIELD)
  	local seq = c:GetPreviousSequence() + 16
  	if c:IsPreviousLocation(LOCATION_SZONE) then
  		seq = seq + 8
  	end
  	return zone and bit.extract(zone, seq) ~= 0
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(s.spcfilter, 1, nil, tp, e:GetHandler())
  end
  function s.filter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_HAND, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND)
  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.filter, tp, LOCATION_HAND, 0, 1, 1, nil, e, tp)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  
  
source_text: Mekk-Knight
  If 2 or more cards are in the same column, you can Special Summon this card (from your hand) in that column. You can only Special Summon "Mekk-Knight Orange Sunset" once per turn this way. If an opponent's card in this card's column is destroyed by battle, or leaves the field: You can Special Summon 1 "Mekk-Knight" monster from your hand.
target_text: -- Mekk-Knight
  local SETCARD_ID_0 = 0x10c --Mekk-Knight
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_FIELD)
  	e1:SetCode(EFFECT_SPSUMMON_PROC)
  	e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCountLimit(1, id + EFFECT_COUNT_CODE_OATH)
  	e1:SetCondition(s.hspcon)
  	e1:SetValue(s.hspval)
  	c:RegisterEffect(e1)
  	--spsummon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O)
  	e2:SetCode(EVENT_LEAVE_FIELD)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_DAMAGE_STEP)
  	e2:SetCondition(s.spcon)
  	e2:SetTarget(s.sptg)
  	e2:SetOperation(s.spop)
  	c:RegisterEffect(e2)
  end
  function s.cfilter(c)
  	return c:GetColumnGroupCount() > 0
  end
  function s.hspcon(e, c)
  	if c == nil then
  		return true
  	end
  	local tp = c:GetControler()
  	local zone = 0
  	local lg = Duel.GetMatchingGroup(s.cfilter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, nil)
  	for tc in aux.Next(lg) do
  		zone = bit.bor(zone, tc:GetColumnZone(LOCATION_MZONE, tp))
  	end
  	return Duel.GetLocationCount(tp, LOCATION_MZONE, tp, LOCATION_REASON_TOFIELD, zone) > 0
  end
  function s.hspval(e, c)
  	local tp = c:GetControler()
  	local zone = 0
  	local lg = Duel.GetMatchingGroup(s.cfilter, tp, LOCATION_ONFIELD, LOCATION_ONFIELD, nil)
  	for tc in aux.Next(lg) do
  		zone = bit.bor(zone, tc:GetColumnZone(LOCATION_MZONE, tp))
  	end
  	return 0, zone
  end
  function s.spcfilter(c, tp, mc)
  	if c:IsPreviousControler(tp) then
  		return false
  	end
  	local zone = mc:GetColumnZone(LOCATION_ONFIELD)
  	local seq = c:GetPreviousSequence() + 16
  	if c:IsPreviousLocation(LOCATION_SZONE) then
  		seq = seq + 8
  	end
  	return zone and bit.extract(zone, seq) ~= 0
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return eg:IsExists(s.spcfilter, 1, nil, tp, e:GetHandler())
  end
  function s.filter(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_HAND, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND)
  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.filter, tp, LOCATION_HAND, 0, 1, 1, nil, e, tp)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  
  