name: Gadget
card_text: You can send this card from your hand to the Graveyard and select any number of face-up "Morphtronic" monsters you control. Change the battle position of the selected monster(s). This effect can be activated during either player's turn.
external_ids: local SETCARD_ID_0 = 0x26 --Morphtronic
  
lua: local SETCARD_ID_0 = 0x26 --Morphtronic
  local s, id, o = GetID()
  function s.initial_effect(c)
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_POSITION)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.tg)
  	e1:SetOperation(s.op)
  	c:RegisterEffect(e1)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsAbleToGraveAsCost()
  	end
  	Duel.SendtoGrave(e:GetHandler(), REASON_COST)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.tg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_POSCHANGE)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 7, nil)
  	Duel.SetOperationInfo(0, CATEGORY_POSITION, g, g:GetCount(), 0, 0)
  end
  function s.tfilter(c, e)
  	return c:IsRelateToEffect(e) and c:IsFaceup()
  end
  function s.op(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	local sg = g:Filter(s.tfilter, nil, e)
  	Duel.ChangePosition(sg, POS_FACEUP_DEFENSE, 0, POS_FACEUP_ATTACK, 0)
  end
  
  
source_text: Gadget
  You can send this card from your hand to the Graveyard and select any number of face-up "Morphtronic" monsters you control. Change the battle position of the selected monster(s). This effect can be activated during either player's turn.
target_text: -- Gadget
  local SETCARD_ID_0 = 0x26 --Morphtronic
  local s, id, o = GetID()
  function s.initial_effect(c)
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_POSITION)
  	e1:SetProperty(EFFECT_FLAG_CARD_TARGET)
  	e1:SetType(EFFECT_TYPE_QUICK_O)
  	e1:SetRange(LOCATION_HAND)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetCost(s.cost)
  	e1:SetTarget(s.tg)
  	e1:SetOperation(s.op)
  	c:RegisterEffect(e1)
  end
  function s.cost(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:GetHandler():IsAbleToGraveAsCost()
  	end
  	Duel.SendtoGrave(e:GetHandler(), REASON_COST)
  end
  function s.filter(c)
  	return c:IsFaceup() and c:IsSetCard(SETCARD_ID_0)
  end
  function s.tg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	if chkc then
  		return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.filter(chkc)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.filter, tp, LOCATION_MZONE, 0, 1, nil)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_POSCHANGE)
  	local g = Duel.SelectTarget(tp, s.filter, tp, LOCATION_MZONE, 0, 1, 7, nil)
  	Duel.SetOperationInfo(0, CATEGORY_POSITION, g, g:GetCount(), 0, 0)
  end
  function s.tfilter(c, e)
  	return c:IsRelateToEffect(e) and c:IsFaceup()
  end
  function s.op(e, tp, eg, ep, ev, re, r, rp)
  	local g = Duel.GetChainInfo(0, CHAININFO_TARGET_CARDS)
  	local sg = g:Filter(s.tfilter, nil, e)
  	Duel.ChangePosition(sg, POS_FACEUP_DEFENSE, 0, POS_FACEUP_ATTACK, 0)
  end
  
  