name: G
card_text: 2 EARTH monsters
  If this card is Special Summoned from the GY: You can target 1 EARTH monster in your GY that can be Normal Summoned/Set; Special Summon it (but negate its effects, also banish it when it leaves the field) or add it to your hand. You can only use this effect of "G Golem Stubborn Menhir" once per turn.
lua: local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkAttribute, ATTRIBUTE_EARTH), 2, 2)
  	c:EnableReviveLimit()
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SPECIAL_SUMMON + CATEGORY_GRAVE_ACTION + CATEGORY_GRAVE_SPSUMMON)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_CARD_TARGET)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsPreviousLocation(LOCATION_GRAVE)
  end
  function s.spfilter(c, e, tp, ft)
  	return c:IsAttribute(ATTRIBUTE_EARTH) and c:IsSummonableCard() and (c:IsAbleToHand() or (ft > 0 and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)))
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.spfilter(chkc, e, tp, ft)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.spfilter, tp, LOCATION_GRAVE, 0, 1, nil, e, tp, ft)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	local g = Duel.SelectTarget(tp, s.spfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp, ft)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		if aux.NecroValleyNegateCheck(tc) then
  			return
  		end
  		if Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and tc:IsCanBeSpecialSummoned(e, 0, tp, false, false) and (not tc:IsAbleToHand() or Duel.SelectOption(tp, 1190, 1152) == 1) then
  			Duel.SpecialSummonStep(tc, 0, tp, tp, false, false, POS_FACEUP)
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_DISABLE)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  			tc:RegisterEffect(e1)
  			local e2 = Effect.CreateEffect(c)
  			e2:SetType(EFFECT_TYPE_SINGLE)
  			e2:SetCode(EFFECT_DISABLE_EFFECT)
  			e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  			e2:SetValue(RESET_TURN_SET)
  			tc:RegisterEffect(e2)
  			local e3 = Effect.CreateEffect(c)
  			e3:SetType(EFFECT_TYPE_SINGLE)
  			e3:SetCode(EFFECT_LEAVE_FIELD_REDIRECT)
  			e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  			e3:SetReset(RESET_EVENT + RESETS_REDIRECT)
  			e3:SetValue(LOCATION_REMOVED)
  			tc:RegisterEffect(e3)
  			Duel.SpecialSummonComplete()
  		else
  			Duel.SendtoHand(tc, nil, REASON_EFFECT)
  		end
  	end
  end
  
  
source_text: G
  2 EARTH monsters
  If this card is Special Summoned from the GY: You can target 1 EARTH monster in your GY that can be Normal Summoned/Set; Special Summon it (but negate its effects, also banish it when it leaves the field) or add it to your hand. You can only use this effect of "G Golem Stubborn Menhir" once per turn.
target_text: -- G
  local s, id, o = GetID()
  function s.initial_effect(c)
  	--link summon
  	aux.AddLinkProcedure(c, aux.FilterBoolFunction(Card.IsLinkAttribute, ATTRIBUTE_EARTH), 2, 2)
  	c:EnableReviveLimit()
  	--special summon
  	local e1 = Effect.CreateEffect(c)
  	e1:SetDescription(aux.Stringid(id, 0))
  	e1:SetCategory(CATEGORY_TOHAND + CATEGORY_SPECIAL_SUMMON + CATEGORY_GRAVE_ACTION + CATEGORY_GRAVE_SPSUMMON)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetCode(EVENT_SPSUMMON_SUCCESS)
  	e1:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_CARD_TARGET)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsPreviousLocation(LOCATION_GRAVE)
  end
  function s.spfilter(c, e, tp, ft)
  	return c:IsAttribute(ATTRIBUTE_EARTH) and c:IsSummonableCard() and (c:IsAbleToHand() or (ft > 0 and c:IsCanBeSpecialSummoned(e, 0, tp, false, false)))
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk, chkc)
  	local ft = Duel.GetLocationCount(tp, LOCATION_MZONE)
  	if chkc then
  		return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.spfilter(chkc, e, tp, ft)
  	end
  	if chk == 0 then
  		return Duel.IsExistingTarget(s.spfilter, tp, LOCATION_GRAVE, 0, 1, nil, e, tp, ft)
  	end
  	Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TARGET)
  	local g = Duel.SelectTarget(tp, s.spfilter, tp, LOCATION_GRAVE, 0, 1, 1, nil, e, tp, ft)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local tc = Duel.GetFirstTarget()
  	if tc:IsRelateToEffect(e) then
  		if aux.NecroValleyNegateCheck(tc) then
  			return
  		end
  		if Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and tc:IsCanBeSpecialSummoned(e, 0, tp, false, false) and (not tc:IsAbleToHand() or Duel.SelectOption(tp, 1190, 1152) == 1) then
  			Duel.SpecialSummonStep(tc, 0, tp, tp, false, false, POS_FACEUP)
  			local e1 = Effect.CreateEffect(c)
  			e1:SetType(EFFECT_TYPE_SINGLE)
  			e1:SetCode(EFFECT_DISABLE)
  			e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  			tc:RegisterEffect(e1)
  			local e2 = Effect.CreateEffect(c)
  			e2:SetType(EFFECT_TYPE_SINGLE)
  			e2:SetCode(EFFECT_DISABLE_EFFECT)
  			e2:SetReset(RESET_EVENT + RESETS_STANDARD)
  			e2:SetValue(RESET_TURN_SET)
  			tc:RegisterEffect(e2)
  			local e3 = Effect.CreateEffect(c)
  			e3:SetType(EFFECT_TYPE_SINGLE)
  			e3:SetCode(EFFECT_LEAVE_FIELD_REDIRECT)
  			e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  			e3:SetReset(RESET_EVENT + RESETS_REDIRECT)
  			e3:SetValue(LOCATION_REMOVED)
  			tc:RegisterEffect(e3)
  			Duel.SpecialSummonComplete()
  		else
  			Duel.SendtoHand(tc, nil, REASON_EFFECT)
  		end
  	end
  end
  
  