name: Powerhold
card_text: Special Summon this card as an Effect Monster (Machine/EARTH/Level 4/ATK 0/DEF 2000), then, you can equip 1 Level 4 Machine "Gadget" monster from your hand or Deck to this card. (This card is also still a Trap.) If Summoned this way, this card gains ATK equal to double the ATK of the monster equipped to it by this effect.
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)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_EQUIP)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--atkup
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCondition(s.atkcon)
  	e2:SetValue(s.atkval)
  	c:RegisterEffect(e2)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:IsCostChecked()
  			and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  			and Duel.IsPlayerCanSpecialSummonMonster(tp, id, 0, TYPES_EFFECT_TRAP_MONSTER, 0, 2000, 4, RACE_MACHINE, ATTRIBUTE_EARTH)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.eqfilter(c, tp)
  	return c:IsRace(RACE_MACHINE) and c:IsLevel(4) and c:IsSetCard(SETCARD_ID_0) and c:CheckUniqueOnField(tp)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not Duel.IsPlayerCanSpecialSummonMonster(tp, id, 0, TYPES_EFFECT_TRAP_MONSTER, 0, 0, 4, RACE_MACHINE, ATTRIBUTE_EARTH) then
  		return
  	end
  	c:AddMonsterAttribute(TYPE_EFFECT + TYPE_TRAP)
  	if Duel.SpecialSummon(c, SUMMON_VALUE_SELF, tp, tp, true, false, POS_FACEUP) == 0 then
  		return
  	end
  	local g = Duel.GetMatchingGroup(s.eqfilter, tp, LOCATION_HAND + LOCATION_DECK, 0, nil, tp)
  	if g:GetCount() > 0 and Duel.GetLocationCount(tp, LOCATION_SZONE) > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
  		Duel.BreakEffect()
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_EQUIP)
  		local tc = g:Select(tp, 1, 1, nil):GetFirst()
  		Duel.Equip(tp, tc, c)
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_EQUIP_LIMIT)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		e1:SetValue(s.eqlimit)
  		tc:RegisterEffect(e1, true)
  		tc:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD, 0, 0)
  	end
  end
  function s.eqlimit(e, c)
  	return e:GetOwner() == c
  end
  function s.atkcon(e)
  	return e:GetHandler():GetSummonType() == SUMMON_TYPE_SPECIAL + SUMMON_VALUE_SELF
  end
  function s.atkval(e, c)
  	local atk = 0
  	local g = c:GetEquipGroup()
  	local tc = g:GetFirst()
  	while tc do
  		if tc:GetFlagEffect(id) ~= 0 and tc:GetAttack() >= 0 then
  			atk = atk + tc:GetAttack() * 2
  		end
  		tc = g:GetNext()
  	end
  	return atk
  end
  
  
source_text: Powerhold
  Special Summon this card as an Effect Monster (Machine/EARTH/Level 4/ATK 0/DEF 2000), then, you can equip 1 Level 4 Machine "Gadget" monster from your hand or Deck to this card. (This card is also still a Trap.) If Summoned this way, this card gains ATK equal to double the ATK of the monster equipped to it by this effect.
target_text: -- Powerhold
  local SETCARD_ID_0 = 0x51 --Gadget
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--Activate
  	local e1 = Effect.CreateEffect(c)
  	e1:SetCategory(CATEGORY_SPECIAL_SUMMON + CATEGORY_EQUIP)
  	e1:SetType(EFFECT_TYPE_ACTIVATE)
  	e1:SetCode(EVENT_FREE_CHAIN)
  	e1:SetTarget(s.target)
  	e1:SetOperation(s.activate)
  	c:RegisterEffect(e1)
  	--atkup
  	local e2 = Effect.CreateEffect(c)
  	e2:SetType(EFFECT_TYPE_SINGLE)
  	e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
  	e2:SetCode(EFFECT_UPDATE_ATTACK)
  	e2:SetRange(LOCATION_MZONE)
  	e2:SetCondition(s.atkcon)
  	e2:SetValue(s.atkval)
  	c:RegisterEffect(e2)
  end
  function s.target(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return e:IsCostChecked()
  			and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0
  			and Duel.IsPlayerCanSpecialSummonMonster(tp, id, 0, TYPES_EFFECT_TRAP_MONSTER, 0, 2000, 4, RACE_MACHINE, ATTRIBUTE_EARTH)
  	end
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, e:GetHandler(), 1, 0, 0)
  end
  function s.eqfilter(c, tp)
  	return c:IsRace(RACE_MACHINE) and c:IsLevel(4) and c:IsSetCard(SETCARD_ID_0) and c:CheckUniqueOnField(tp)
  end
  function s.activate(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	if not Duel.IsPlayerCanSpecialSummonMonster(tp, id, 0, TYPES_EFFECT_TRAP_MONSTER, 0, 0, 4, RACE_MACHINE, ATTRIBUTE_EARTH) then
  		return
  	end
  	c:AddMonsterAttribute(TYPE_EFFECT + TYPE_TRAP)
  	if Duel.SpecialSummon(c, SUMMON_VALUE_SELF, tp, tp, true, false, POS_FACEUP) == 0 then
  		return
  	end
  	local g = Duel.GetMatchingGroup(s.eqfilter, tp, LOCATION_HAND + LOCATION_DECK, 0, nil, tp)
  	if g:GetCount() > 0 and Duel.GetLocationCount(tp, LOCATION_SZONE) > 0 and Duel.SelectYesNo(tp, aux.Stringid(id, 0)) then
  		Duel.BreakEffect()
  		Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_EQUIP)
  		local tc = g:Select(tp, 1, 1, nil):GetFirst()
  		Duel.Equip(tp, tc, c)
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetCode(EFFECT_EQUIP_LIMIT)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		e1:SetValue(s.eqlimit)
  		tc:RegisterEffect(e1, true)
  		tc:RegisterFlagEffect(id, RESET_EVENT + RESETS_STANDARD, 0, 0)
  	end
  end
  function s.eqlimit(e, c)
  	return e:GetOwner() == c
  end
  function s.atkcon(e)
  	return e:GetHandler():GetSummonType() == SUMMON_TYPE_SPECIAL + SUMMON_VALUE_SELF
  end
  function s.atkval(e, c)
  	local atk = 0
  	local g = c:GetEquipGroup()
  	local tc = g:GetFirst()
  	while tc do
  		if tc:GetFlagEffect(id) ~= 0 and tc:GetAttack() >= 0 then
  			atk = atk + tc:GetAttack() * 2
  		end
  		tc = g:GetNext()
  	end
  	return atk
  end
  
  