name: Seleglare
card_text: You can Normal Summon/Set this card without Tributing, but its original ATK becomes 1500. During the Main Phase (Quick Effect): You can target 1 monster your opponent controls with ATK less than or equal to this card; return this card to the hand, and if you do, take control of that opponent's monster until the End Phase. You can only use this effect of "Seleglare the Luminous Lunar Dragon" once per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--summon & set with no tribute
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_SUMMON_PROC)
  	e1:SetCondition(s.ntcon)
  	e1:SetOperation(s.ntop)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_SET_PROC)
  	c:RegisterEffect(e2)
  	--control
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_TOHAND + CATEGORY_CONTROL)
  	e3:SetType(EFFECT_TYPE_QUICK_O)
  	e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e3:SetCode(EVENT_FREE_CHAIN)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id)
  	e3:SetHintTiming(0, TIMING_MAIN_END)
  	e3:SetCondition(s.ctcon)
  	e3:SetTarget(s.cttg)
  	e3:SetOperation(s.ctop)
  	c:RegisterEffect(e3)
  end
  function s.ntcon(e, c, minc)
  	if c == nil then
  		return true
  	end
  	return minc == 0 and c:IsLevelAbove(5) and Duel.GetLocationCount(c:GetControler(), LOCATION_MZONE) > 0
  end
  function s.ntop(e, tp, eg, ep, ev, re, r, rp, c)
  	--change base attack
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetReset(RESET_EVENT + 0xff0000)
  	e1:SetCode(EFFECT_SET_BASE_ATTACK)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetValue(1500)
  	c:RegisterEffect(e1)
  end
  function s.ctcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetCurrentPhase() == PHASE_MAIN1 or Duel.GetCurrentPhase() == PHASE_MAIN2
  end
  function s.ctfilter(c, atk)
  	return c:IsFaceup() and c:IsAttackBelow(atk) and c:IsControlerCanBeChanged(true)
  end
  function s.cttg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local c = e:GetHandler()
  	local atk = c:GetAttack()
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1 - tp) and s.ctfilter(chkc, atk)
  	end
  	if chk == 0 then
  		return c:IsAbleToHand() and Duel.GetMZoneCount(tp, c, tp, LOCATION_REASON_CONTROL) > 0 and Duel.IsExistingTarget(s.ctfilter, tp, 0, LOCATION_MZONE, 1, nil, atk)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONTROL)
  	local g = Duel.SelectTarget(tp, s.ctfilter, tp, 0, LOCATION_MZONE, 1, 1, nil, atk)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, c, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_CONTROL, g, 1, 0, 0)
  end
  function s.ctop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if c:IsRelateToEffect(e) and Duel.SendtoHand(c, nil, REASON_EFFECT) ~= 0 and c:IsLocation(LOCATION_HAND) and tc:IsRelateToEffect(e) then
  		Duel.GetControl(tc, tp, PHASE_END, 1)
  	end
  end
  
  
source_text: Seleglare
  You can Normal Summon/Set this card without Tributing, but its original ATK becomes 1500. During the Main Phase (Quick Effect): You can target 1 monster your opponent controls with ATK less than or equal to this card; return this card to the hand, and if you do, take control of that opponent's monster until the End Phase. You can only use this effect of "Seleglare the Luminous Lunar Dragon" once per turn.
target_text: -- Seleglare
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--summon & set with no tribute
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetCode(EFFECT_SUMMON_PROC)
  	e1:SetCondition(s.ntcon)
  	e1:SetOperation(s.ntop)
  	c:RegisterEffect(e1)
  	local e2 = e1:Clone()
  	e2:SetCode(EFFECT_SET_PROC)
  	c:RegisterEffect(e2)
  	--control
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_TOHAND + CATEGORY_CONTROL)
  	e3:SetType(EFFECT_TYPE_QUICK_O)
  	e3:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e3:SetCode(EVENT_FREE_CHAIN)
  	e3:SetRange(LOCATION_MZONE)
  	e3:SetCountLimit(1, id)
  	e3:SetHintTiming(0, TIMING_MAIN_END)
  	e3:SetCondition(s.ctcon)
  	e3:SetTarget(s.cttg)
  	e3:SetOperation(s.ctop)
  	c:RegisterEffect(e3)
  end
  function s.ntcon(e, c, minc)
  	if c == nil then
  		return true
  	end
  	return minc == 0 and c:IsLevelAbove(5) and Duel.GetLocationCount(c:GetControler(), LOCATION_MZONE) > 0
  end
  function s.ntop(e, tp, eg, ep, ev, re, r, rp, c)
  	--change base attack
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetReset(RESET_EVENT + 0xff0000)
  	e1:SetCode(EFFECT_SET_BASE_ATTACK)
  	e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetValue(1500)
  	c:RegisterEffect(e1)
  end
  function s.ctcon(e, tp, eg, ep, ev, re, r, rp)
  	return Duel.GetCurrentPhase() == PHASE_MAIN1 or Duel.GetCurrentPhase() == PHASE_MAIN2
  end
  function s.ctfilter(c, atk)
  	return c:IsFaceup() and c:IsAttackBelow(atk) and c:IsControlerCanBeChanged(true)
  end
  function s.cttg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local c = e:GetHandler()
  	local atk = c:GetAttack()
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1 - tp) and s.ctfilter(chkc, atk)
  	end
  	if chk == 0 then
  		return c:IsAbleToHand() and Duel.GetMZoneCount(tp, c, tp, LOCATION_REASON_CONTROL) > 0 and Duel.IsExistingTarget(s.ctfilter, tp, 0, LOCATION_MZONE, 1, nil, atk)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CONTROL)
  	local g = Duel.SelectTarget(tp, s.ctfilter, tp, 0, LOCATION_MZONE, 1, 1, nil, atk)
  	Duel.SetOperationInfo(0, CATEGORY_TOHAND, c, 1, 0, 0)
  	Duel.SetOperationInfo(0, CATEGORY_CONTROL, g, 1, 0, 0)
  end
  function s.ctop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if c:IsRelateToEffect(e) and Duel.SendtoHand(c, nil, REASON_EFFECT) ~= 0 and c:IsLocation(LOCATION_HAND) and tc:IsRelateToEffect(e) then
  		Duel.GetControl(tc, tp, PHASE_END, 1)
  	end
  end
  
  