name: Triggering
card_text: If this card is sent to the GY as Link Material for the Link Summon of a DARK monster: You can Special Summon this card from your GY in Attack Position, to your zone that Link Monster points to, but it cannot be used as Link Material. If this card is destroyed or banished by an effect activated by a Link Monster: Draw 1 card. You can only use each effect of "Triggering Wurm" once per turn.
lua: 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_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCode(EVENT_BE_MATERIAL)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	aux.CreateMaterialReasonCardRelation(c, e1)
  	--draw
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_DRAW)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e2:SetCode(EVENT_DESTROYED)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCondition(s.drcon)
  	e2:SetTarget(s.drtg)
  	e2:SetOperation(s.drop)
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetCode(EVENT_REMOVE)
  	c:RegisterEffect(e3)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsLocation(LOCATION_GRAVE) and r == REASON_LINK and c:GetReasonCard():IsAttribute(ATTRIBUTE_DARK)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	local rc = c:GetReasonCard()
  	if chk == 0 then
  		local zone = bit.band(rc:GetLinkedZone(tp), 0x1f)
  		return rc:IsRelateToEffect(e) and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_ATTACK, tp, zone)
  	end
  	Duel.SetTargetCard(rc)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, c, 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local rc = Duel.GetFirstTarget()
  	if not rc:IsRelateToChain() then
  		return
  	end
  	local zone = bit.band(rc:GetLinkedZone(tp), 0x1f)
  	if c:IsRelateToEffect(e) and zone ~= 0 and Duel.SpecialSummonStep(c, 0, tp, tp, false, false, POS_FACEUP_ATTACK, zone) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetCode(EFFECT_CANNOT_BE_LINK_MATERIAL)
  		e1:SetValue(1)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		c:RegisterEffect(e1, true)
  	end
  	Duel.SpecialSummonComplete()
  end
  function s.drcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsReason(REASON_EFFECT) and re:IsActiveType(TYPE_LINK) and re:IsActivated()
  end
  function s.drtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetTargetPlayer(tp)
  	Duel.SetTargetParam(1)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 1)
  end
  function s.drop(e, tp, eg, ep, ev, re, r, rp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	Duel.Draw(p, d, REASON_EFFECT)
  end
  
  
source_text: Triggering
  If this card is sent to the GY as Link Material for the Link Summon of a DARK monster: You can Special Summon this card from your GY in Attack Position, to your zone that Link Monster points to, but it cannot be used as Link Material. If this card is destroyed or banished by an effect activated by a Link Monster: Draw 1 card. You can only use each effect of "Triggering Wurm" once per turn.
target_text: -- Triggering
  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_SPECIAL_SUMMON)
  	e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O)
  	e1:SetProperty(EFFECT_FLAG_DELAY)
  	e1:SetCode(EVENT_BE_MATERIAL)
  	e1:SetCountLimit(1, id)
  	e1:SetCondition(s.spcon)
  	e1:SetTarget(s.sptg)
  	e1:SetOperation(s.spop)
  	c:RegisterEffect(e1)
  	aux.CreateMaterialReasonCardRelation(c, e1)
  	--draw
  	local e2 = Effect.CreateEffect(c)
  	e2:SetDescription(aux.Stringid(id, 1))
  	e2:SetCategory(CATEGORY_DRAW)
  	e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
  	e2:SetCode(EVENT_DESTROYED)
  	e2:SetCountLimit(1, id + 1)
  	e2:SetCondition(s.drcon)
  	e2:SetTarget(s.drtg)
  	e2:SetOperation(s.drop)
  	c:RegisterEffect(e2)
  	local e3 = e2:Clone()
  	e3:SetCode(EVENT_REMOVE)
  	c:RegisterEffect(e3)
  end
  function s.spcon(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	return c:IsLocation(LOCATION_GRAVE) and r == REASON_LINK and c:GetReasonCard():IsAttribute(ATTRIBUTE_DARK)
  end
  function s.sptg(e, tp, eg, ep, ev, re, r, rp, chk)
  	local c = e:GetHandler()
  	local rc = c:GetReasonCard()
  	if chk == 0 then
  		local zone = bit.band(rc:GetLinkedZone(tp), 0x1f)
  		return rc:IsRelateToEffect(e) and Duel.GetLocationCount(tp, LOCATION_MZONE) > 0 and c:IsCanBeSpecialSummoned(e, 0, tp, false, false, POS_FACEUP_ATTACK, tp, zone)
  	end
  	Duel.SetTargetCard(rc)
  	Duel.SetOperationInfo(0, CATEGORY_SPECIAL_SUMMON, c, 1, 0, 0)
  end
  function s.spop(e, tp, eg, ep, ev, re, r, rp)
  	local c = e:GetHandler()
  	local rc = Duel.GetFirstTarget()
  	if not rc:IsRelateToChain() then
  		return
  	end
  	local zone = bit.band(rc:GetLinkedZone(tp), 0x1f)
  	if c:IsRelateToEffect(e) and zone ~= 0 and Duel.SpecialSummonStep(c, 0, tp, tp, false, false, POS_FACEUP_ATTACK, zone) then
  		local e1 = Effect.CreateEffect(c)
  		e1:SetType(EFFECT_TYPE_SINGLE)
  		e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
  		e1:SetCode(EFFECT_CANNOT_BE_LINK_MATERIAL)
  		e1:SetValue(1)
  		e1:SetReset(RESET_EVENT + RESETS_STANDARD)
  		c:RegisterEffect(e1, true)
  	end
  	Duel.SpecialSummonComplete()
  end
  function s.drcon(e, tp, eg, ep, ev, re, r, rp)
  	return e:GetHandler():IsReason(REASON_EFFECT) and re:IsActiveType(TYPE_LINK) and re:IsActivated()
  end
  function s.drtg(e, tp, eg, ep, ev, re, r, rp, chk)
  	if chk == 0 then
  		return true
  	end
  	Duel.SetTargetPlayer(tp)
  	Duel.SetTargetParam(1)
  	Duel.SetOperationInfo(0, CATEGORY_DRAW, nil, 0, tp, 1)
  end
  function s.drop(e, tp, eg, ep, ev, re, r, rp)
  	local p, d = Duel.GetChainInfo(0, CHAININFO_TARGET_PLAYER, CHAININFO_TARGET_PARAM)
  	Duel.Draw(p, d, REASON_EFFECT)
  end
  
  