name: Meklord
card_text: When a "Meklord" monster on the field is targeted for an attack: Target 1 "Meklord Army" monster in your Graveyard; add that target to your hand, then destroy the attack target.
external_ids: local SETCARD_ID_0 = 0x13 --Meklord
  local SETCARD_ID_1 = 0x6013 --Meklord
  
lua: local SETCARD_ID_0 = 0x13 --Meklord
  local SETCARD_ID_1 = 0x6013 --Meklord
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_DESTROY)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_BE_BATTLE_TARGET)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	local d = Duel.GetAttackTarget()
  	return d:IsFaceup() and d:IsSetCard(SETCARD_ID_1)
  end
  function s.filter(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsAbleToHand()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	local d = Duel.GetAttackTarget()
  	d:RegisterFlagEffect(id, RESET_EVENT + 0x3fe0000, 0, 1)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, d, 1, 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.SendtoHand(tc, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, tc)
  		local d = Duel.GetAttackTarget()
  		if d:GetFlagEffect(id) ~= 0 then
  			Duel.Destroy(d, REASON_EFFECT)
  		end
  	end
  end
  
  
source_text: Meklord
  When a "Meklord" monster on the field is targeted for an attack: Target 1 "Meklord Army" monster in your Graveyard; add that target to your hand, then destroy the attack target.
target_text: -- Meklord
  local SETCARD_ID_0 = 0x13 --Meklord
  local SETCARD_ID_1 = 0x6013 --Meklord
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_DESTROY)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_BE_BATTLE_TARGET)
  	e1:SetCondition(s.condition)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  end
  function s.condition(e, tp, eg, ep, ev, re, r, rp)
  	local d = Duel.GetAttackTarget()
  	return d:IsFaceup() and d:IsSetCard(SETCARD_ID_1)
  end
  function s.filter(c)
  	return c:IsSetCard(SETCARD_ID_1) and c:IsAbleToHand()
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_GRAVE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_ATOHAND)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_GRAVE, 0, 1, 1, nil)
  	local d = Duel.GetAttackTarget()
  	d:RegisterFlagEffect(id, RESET_EVENT + 0x3fe0000, 0, 1)
  	Duel.SetOperationInfo(0, CATEGORY_DESTROY, d, 1, 0, 0)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		Duel.SendtoHand(tc, nil, REASON_EFFECT)
  		Duel.ConfirmCards(1 - tp, tc)
  		local d = Duel.GetAttackTarget()
  		if d:GetFlagEffect(id) ~= 0 then
  			Duel.Destroy(d, REASON_EFFECT)
  		end
  	end
  end
  
  