name: Morphtronic
card_text: ● While in Attack Position: Once per turn, you can roll a six-sided die. Reveal cards from top of your Deck equal to the roll and Special Summon 1 Level 4 or lower "Morphtronic" monster from among them, ignoring the Summoning conditions. Shuffle the rest into the Deck.
  ● While in Defense Position: Once per turn, you can roll a six-sided die. Look at cards from top of your Deck equal to the roll, then return them in the same order.
external_ids: local CARD_ID_0 = 63060238 --Elemental HERO Blazeman
  local SETCARD_ID_0 = 0x26 --Morphtronic
  
lua: local CARD_ID_0 = 63060238 --Elemental HERO Blazeman
  local SETCARD_ID_0 = 0x26 --Morphtronic
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DICE + CATEGORY_SPECIAL_SUMMON + CATEGORY_DECKDES)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetCountLimit(1)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCondition(s.cona)
  	e1:SetTarget(s.tga)
  	e1:SetOperation(s.opa)
  	c:RegisterEffect(e1)
  	--confirm
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_DICE)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetCountLimit(1)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCondition(s.cond)
  	e2:SetTarget(s.tgd)
  	e2:SetOperation(s.opd)
  	c:RegisterEffect(e2)
  end
  function s.cona(e, tp, eg, ep, ev, re, r, rp)
  	return not e:GetHandler():IsDisabled() and e:GetHandler():IsAttackPos()
  end
  function s.cond(e, tp, eg, ep, ev, re, r, rp)
  	return not e:GetHandler():IsDisabled() and e:GetHandler():IsDefensePos()
  end
  function s.tga(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanSpecialSummon(tp)
  			and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  			and not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0)
  			and Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) > 0
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DICE, nil, 0, tp, 1)
  end
  function s.tgd(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) > 0
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DICE, nil, 0, tp, 1)
  end
  function s.filter(c, e, tp)
  	return c:IsLevelBelow(4) and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsCanBeSpecialSummoned(e, 0, tp, true, false)
  end
  function s.opa(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) == 0 then
  		return
  	end
  	local dc = Duel.TossDice(tp, 1)
  	Duel.ConfirmDecktop(tp, dc)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	local g = Duel.GetDecktopGroup(tp, dc)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local sg = g:FilterSelect(tp, s.filter, 1, 1, nil, e, tp)
  	Duel.SpecialSummon(sg, 0, tp, tp, true, false, POS_FACEUP)
  	Duel.ShuffleDeck(tp)
  end
  function s.opd(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) == 0 then
  		return
  	end
  	local dc = Duel.TossDice(tp, 1)
  	local g = Duel.GetDecktopGroup(tp, dc)
  	Duel.ConfirmCards(tp, g)
  end
  
  
source_text: Morphtronic
  ● While in Attack Position: Once per turn, you can roll a six-sided die. Reveal cards from top of your Deck equal to the roll and Special Summon 1 Level 4 or lower "Morphtronic" monster from among them, ignoring the Summoning conditions. Shuffle the rest into the Deck.
  ● While in Defense Position: Once per turn, you can roll a six-sided die. Look at cards from top of your Deck equal to the roll, then return them in the same order.
target_text: -- Morphtronic
  local CARD_ID_0 = 63060238 --Elemental HERO Blazeman
  local SETCARD_ID_0 = 0x26 --Morphtronic
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_DICE + CATEGORY_SPECIAL_SUMMON + CATEGORY_DECKDES)
  	e1:SetType(EFFECT_TYPE_IGNITION)
  	e1:SetCountLimit(1)
  	e1:SetRange(LOCATION_MZONE)
  	e1:SetCondition(s.cona)
  	e1:SetTarget(s.tga)
  	e1:SetOperation(s.opa)
  	c:RegisterEffect(e1)
  	--confirm
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_DICE)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetCountLimit(1)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCondition(s.cond)
  	e2:SetTarget(s.tgd)
  	e2:SetOperation(s.opd)
  	c:RegisterEffect(e2)
  end
  function s.cona(e, tp, eg, ep, ev, re, r, rp)
  	return not e:GetHandler():IsDisabled() and e:GetHandler():IsAttackPos()
  end
  function s.cond(e, tp, eg, ep, ev, re, r, rp)
  	return not e:GetHandler():IsDisabled() and e:GetHandler():IsDefensePos()
  end
  function s.tga(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.IsPlayerCanSpecialSummon(tp)
  			and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  			and not Duel.IsPlayerAffectedByEffect(tp, CARD_ID_0)
  			and Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) > 0
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DICE, nil, 0, tp, 1)
  end
  function s.tgd(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) > 0
  	end
  	Duel.SetOperationInfo(0, CATEGORY_DICE, nil, 0, tp, 1)
  end
  function s.filter(c, e, tp)
  	return c:IsLevelBelow(4) and c:IsSetCard(SETCARD_ID_0) and c:IsType(TYPE_MONSTER) and c:IsCanBeSpecialSummoned(e, 0, tp, true, false)
  end
  function s.opa(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) == 0 then
  		return
  	end
  	local dc = Duel.TossDice(tp, 1)
  	Duel.ConfirmDecktop(tp, dc)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE) <= 0 then
  		return
  	end
  	local g = Duel.GetDecktopGroup(tp, dc)
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local sg = g:FilterSelect(tp, s.filter, 1, 1, nil, e, tp)
  	Duel.SpecialSummon(sg, 0, tp, tp, true, false, POS_FACEUP)
  	Duel.ShuffleDeck(tp)
  end
  function s.opd(e, tp, eg, ep, ev, re, r, rp)
  	if Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) == 0 then
  		return
  	end
  	local dc = Duel.TossDice(tp, 1)
  	local g = Duel.GetDecktopGroup(tp, dc)
  	Duel.ConfirmCards(tp, g)
  end
  
  