name: Platinum
card_text: 2 Machine monsters
  Cannot be used as Link Material the turn it is Link Summoned. During your Main Phase: You can Special Summon 1 Level 4 or lower Machine monster from your hand to your zone this card points to. If this card is destroyed by battle or card effect: You can Special Summon 1 Level 4 "Gadget" monster from your Deck. You can only use each effect of "Platinum Gadget" once per turn.
external_ids: local SETCARD_ID_0 = 0x51 --Gadget
  
lua: local SETCARD_ID_0 = 0x51 --Gadget
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	c:EnableReviveLimit()
  	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkRace, RACE_MACHINE), 2, 2)
  	--cannot link material
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_CANNOT_BE_LINK_MATERIAL)
  	e1:SetCondition(s.linkcon)
  	e1:SetValue(1)
  	c:RegisterEffect(e1)
  	--special summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetTarget(s.sptg1)
  	e2:SetOperation(s.spop1)
  	c:RegisterEffect(e2)
  	--special summon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetProperty(EFFECT_FLAG_DELAY)
  	e3:SetCode(EVENT_DESTROYED)
  	e3:SetCountLimit(1, id + 1)
  	e3:SetCondition(s.spcon2)
  	e3:SetTarget(s.sptg2)
  	e3:SetOperation(s.spop2)
  	c:RegisterEffect(e3)
  end
  function s.linkcon(e)
  	local c = e:GetHandler()
  	return c:IsStatus(STATUS_SPSUMMON_TURN) and c:IsSummonType(SUMMON_TYPE_LINK)
  end
  function s.spfilter1(c, e, tp, zone)
  	return c:IsRace(RACE_MACHINE) and c:IsLevelBelow(4) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP, tp, zone)
  end
  function s.sptg1(e, tp, eg, ep, ev, re, r, rp, chk)
  	local zone = e:GetHandler():GetLinkedZone(tp)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.spfilter1, tp, LOCATION_HAND, 0, 1, nil, e, tp, zone)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND)
  end
  function s.spop1(e, tp, eg, ep, ev, re, r, rp)
  	local zone = e:GetHandler():GetLinkedZone(tp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE, tp, LOCATION_REASON_TOFIELD, zone) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter1, tp, LOCATION_HAND, 0, 1, 1, nil, e, tp, zone)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP, zone)
  	end
  end
  function s.spcon2(e, tp, eg, ep, ev, re, r, rp)
  	return bit.band(r, REASON_EFFECT + REASON_BATTLE) ~= 0
  end
  function s.spfilter2(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsLevel(4) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg2(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter2, tp, LOCATION_DECK, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK)
  end
  function s.spop2(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.spfilter2, tp, LOCATION_DECK, 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: Platinum
  2 Machine monsters
  Cannot be used as Link Material the turn it is Link Summoned. During your Main Phase: You can Special Summon 1 Level 4 or lower Machine monster from your hand to your zone this card points to. If this card is destroyed by battle or card effect: You can Special Summon 1 Level 4 "Gadget" monster from your Deck. You can only use each effect of "Platinum Gadget" once per turn.
target_text: -- Platinum
  local SETCARD_ID_0 = 0x51 --Gadget
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	c:EnableReviveLimit()
  	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkRace, RACE_MACHINE), 2, 2)
  	--cannot link material
  	local e1 = Effect.CreateEffect(c)
  	e1:SetType(EFFECT_TYPE_SINGLE)
  	e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
  	e1:SetCode(EFFECT_CANNOT_BE_LINK_MATERIAL)
  	e1:SetCondition(s.linkcon)
  	e1:SetValue(1)
  	c:RegisterEffect(e1)
  	--special summon
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 0))
  	e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e2:SetType(EFFECT_TYPE_IGNITION)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCountLimit(1, id)
  	e2:SetTarget(s.sptg1)
  	e2:SetOperation(s.spop1)
  	c:RegisterEffect(e2)
  	--special summon
  	local e3 = Effect.CreateEffect(c)
  	e3:SetDescription(aux.Stringid(id, 1))
  	e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
  	e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e3:SetProperty(EFFECT_FLAG_DELAY)
  	e3:SetCode(EVENT_DESTROYED)
  	e3:SetCountLimit(1, id + 1)
  	e3:SetCondition(s.spcon2)
  	e3:SetTarget(s.sptg2)
  	e3:SetOperation(s.spop2)
  	c:RegisterEffect(e3)
  end
  function s.linkcon(e)
  	local c = e:GetHandler()
  	return c:IsStatus(STATUS_SPSUMMON_TURN) and c:IsSummonType(SUMMON_TYPE_LINK)
  end
  function s.spfilter1(c, e, tp, zone)
  	return c:IsRace(RACE_MACHINE) and c:IsLevelBelow(4) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP, tp, zone)
  end
  function s.sptg1(e, tp, eg, ep, ev, re, r, rp, chk)
  	local zone = e:GetHandler():GetLinkedZone(tp)
  	if chk == 0 then
  		return Duel.IsExistingMatchingCard(s.spfilter1, tp, LOCATION_HAND, 0, 1, nil, e, tp, zone)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_HAND)
  end
  function s.spop1(e, tp, eg, ep, ev, re, r, rp)
  	local zone = e:GetHandler():GetLinkedZone(tp)
  	if Duel.GetLocationCount(tp, LOCATION_MZONE, tp, LOCATION_REASON_TOFIELD, zone) <= 0 then
  		return
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_SPSUMMON)
  	local g = Duel.SelectMatchingCard(tp, s.spfilter1, tp, LOCATION_HAND, 0, 1, 1, nil, e, tp, zone)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP, zone)
  	end
  end
  function s.spcon2(e, tp, eg, ep, ev, re, r, rp)
  	return bit.band(r, REASON_EFFECT + REASON_BATTLE) ~= 0
  end
  function s.spfilter2(c, e, tp)
  	return c:IsSetCard(SETCARD_ID_0) and c:IsLevel(4) and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)
  end
  function s.sptg2(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and Duel.IsExistingMatchingCard(s.spfilter2, tp, LOCATION_DECK, 0, 1, nil, e, tp)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, nil, 1, tp, LOCATION_DECK)
  end
  function s.spop2(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.spfilter2, tp, LOCATION_DECK, 0, 1, 1, nil, e, tp)
  	if g:GetCount() > 0 then
  		Duel.SpecialSummon(g, 0, tp, tp, false, false, POS_FACEUP)
  	end
  end
  
  